com.unity.netcode.gameobjects
com.unity.netcode.gameobjects copied to clipboard
Owner Authoritative NetworkAnimator does not work properly when ownership is assigned after spawning
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
- Spawn an owner authoritative
NetworkAnimatorwith the server as the owner - Change the ownership of the
NetworkAnimatorto a non-host client - 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 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. 👍
Backlog: MTT-4460
#2127 contains the fix for this issue and should be in the next update!