NullReferenceException: Object reference not set to an instance of an object
Unity.Netcode.Components.NetworkAnimator.CheckParametersChanged () (at ./Library/PackageCache/com.unity.netcode.gameobjects@837011a5fcd5/Runtime/Components/NetworkAnimator.cs:1072)
Unity.Netcode.Components.NetworkAnimator.CheckForAnimatorChanges () (at ./Library/PackageCache/com.unity.netcode.gameobjects@837011a5fcd5/Runtime/Components/NetworkAnimator.cs:957)
Unity.Netcode.Components.NetworkAnimatorStateChangeHandler.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@837011a5fcd5/Runtime/Components/NetworkAnimator.cs:102)
Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@837011a5fcd5/Runtime/Core/NetworkUpdateLoop.cs:191)
Unity.Netcode.NetworkUpdateLoop+NetworkPreUpdate+<>c.<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects@837011a5fcd5/Runtime/Core/NetworkUpdateLoop.cs:238)
#I am receiving a NetworkAnimator.CheckParametersChanged error.
1 messages · Page 1 of 1 (latest)
I don't understand how to fix it, even though the animation from the child object is transferred to the parent.
I would guess the error is happening because the animator is not set before the network starts. And setting it afterwards doesn't seemt to fix it.
So you would either need to set it before the network starts
or
have the NetworkAnimator disabled by default, set the animator and then enable it
You can also try finding a solution that allows for the animator to be set on the prefab to avoid all of this.
How do you think it should be set up before the start?
Before the start, the prefab looks like this
After selecting a character and starting the game, the selected character is transferred.
This is why the network animator should be disabled until you have the animator to assign to it
It's giving this error message even when disabled?
open a bug report on that. I'm not sure why any Update() is running on a disabled component. As a workaround you can put an Animator or on the Player prefab
If I am a regular animator and upload a player prefab, how will I receive the character animation?
However, the error still occurs even if the network animator is disabled on the player prefab.
Do all of your characters use the same states? Ex. Walk, Run, Jump, etc.
yes
I think you might have better luck putting NetworkAnimator and the regular Animator on the Player Prefab itself. Then through your script swap out the Controller field on the regular Animator.
And I would also use Animation Override Controllers as well.
NetworkAnimator hangs on the player prefab, the regular animator on the selected character is also a prefab.
So you can drag in the base controller by default just as a placeholder so it can register all the parameters, and then through script your can swap in an overrice controller her each hero.
Yeah. I'm saying to put both on the Player Prefab.
Correct, and then you would set Animator.runtimeAnimatorController through script
with each hero's specific controller
There are no errors, but the animation does not work.
Did you do this?
Where can it be used?
I don't know what you're asking.
As you suggest, the animation does not function at all.
Because you did 1 step out of multiple that I suggested.
I don't understand what you're offering me.
- Put
OwnerNetworkAnimatorandAnimatoron your Player prefab. - Create one
Animator Controllerthat has all the states your player needs. Drag it in to theAnimatoron the Player prefab. - Create an
Animator Override Controllerfor each hero and their specific animations. - Create a script
HeroAnimatorDatathat will be attached to each hero prefab that holds itsAnimator Override Controller. Should just be a script with a single variable, something likepublic AnimatorOverrideController heroAnimatorController; - In your
NetworkPlayerSpawnscript you can dovar heroAnimationController = selectedCharacterPrefab.GetComponent<HeroAnimatorData>().heroAnimatorControllerand then doplayerController.ownerNetworkAnimator.Animator.runtimeAnimatorController = heroAnimatorController
If you don't understand an individual step, feel free to ask.
You can change up the last step to use your SetAnimator function on the player controller if you want.
Are you adding or destroying any components on the player at runtime?
No, I'm not deleting it.
when there is only one customer, everything is fine
Are you creating a build? There are not many reasons why the prefabs would be different between client and server
host in Unity, second player in the build
You might need rebuild
I just launched two builds, etc., but the error remains.
Build the application again - not run two builds.
It doesn't help. I'm writing about it.
Works only on the first player, error on the second
We also can't see the line that is erroring. (PlayerController Line 90)
I would also reccomend using Multiplayer Play Mode or ParrelSync. Would make tracking down errors like this much easier.
PlayerController Line 90
it's because of the first mistake
Why are you looking at what happens next? If the problem is initially in the first error, which causes the following errors,
Just because the errors are logged in that order does not mean the first causes the other.
We've also already told you what causes the first error. I'm just trying to get a full picture of what's happening currently.
What happens is that there is a player prefab in which the selected character appears, which has a normal and network animator. On the host, everything is fine, but on other players, the first error is triggered.
It's saying NetworkBehaviour at index 2 is out of bounds, which means it can't find it on your clients. That means the third NetworkBehaviour on your Player object.
index 0 - PlayerController
index 1 - ClientNetworkTransform
index 2 - OwnerNetworkAnimator
So the network is starting, and because you haven't manually spawned the Hero/Character prefab with the OwnerNetworkAnimator on it yet, it's erroring.
This is one of the reasons I recommended putting OwnerNetworkAnimator on the Player prefab.
Yes, it was hanging there, and there was another mistake.
I even checked with Monke, and he also has animation running on his daughter's computer, and everything works fine.
Because it's a part of the prefab.
Yours is not.
You're adding it at runtime.
What if I add them in advance and simply disable them? And enable them if the player selects that character?
That works.
People just tend to avoid doing that because that solution doesn't scale well. But if you only have a handful of heroes/characters, it's fine.
I have 20 characters.
Yeah. That may be problematic.
What I've done in the past is swap out the mesh renderer and materials. Which works as long as the animation avatar is the same between characters
The other thing you could try is just combing your hero and player prefabs. Put all the network and player scripts right on the heroes and spawn that.
I'm not sure if NGO has a problem with Player objects being different, but I don't think it would.
You'd have to have them all enabled by default, disable them after the player spawns and keep the selected one enabled.
If they have network behaviors on them then they would need to be enabled at spawn. You can disable the renderer on them
I still get an error even if they are all enabled and then disabled.
Don't disable the objects at all. just disable the renderer
In general, I don't understand how to disable them for other players.
You'll need to use RPCs or Network Variables. I would have a NetworkVariable<int> that the player can set. 3 will enable the renderer on the 3rd child and disable the renderer on the rest
This is a singleton. the network variable here will be the same for all clients
I disabled rendering for all characters, and it only turns on for the host; the client refuses to turn on via RPC.
post the code for your PRC
👏