com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Owner Authoritative NetworkAnimator does not work properly when ownership is assigned after spawning

Open dunorb opened this issue 3 years ago • 2 comments

Description

NetworkAnimator does some setup in OnNetworkSpawn that is behind a check of if (IsOwner || IsServer) If a client spawns a NetworkAnimator without ownership and then later receives ownership, this setup is never done, which leads to errors.

I believe a simple fix could be to do the necessary setup in OnGainedOwnership

Reproduce Steps

  1. Spawn an owner authoritative NetworkAnimator with the server as the owner
  2. Change the ownership of the NetworkAnimator to a non-host client
  3. Errors are thrown every frame as a result of null member variables

Actual Outcome

Owner Authoritative NetworkAnimators throw errors when changing ownership to a another client.

Expected Outcome

Owner Authoritative NetworkAnimators should properly set up when given ownership.

Environment

  • OS: Windows 10
  • Unity Version: 2021.2
  • Netcode Version: 1.0.0

dunorb avatar Aug 16 '22 08:08 dunorb

@dunorb I will take a closer look to see if this is something that could make it into the next patch, but just seeing that there are no OnGainedOwnership or OnLostOwnership overrides I am confident that this indeed is something that requires a fix indeed!

Thank you for taking the time to point this out. 👍

NoelStephensUnity avatar Aug 16 '22 22:08 NoelStephensUnity

Backlog: MTT-4460

ashwinimurt avatar Aug 22 '22 20:08 ashwinimurt

#2127 contains the fix for this issue and should be in the next update!

NoelStephensUnity avatar Sep 28 '22 22:09 NoelStephensUnity