#I am receiving a NetworkAnimator.CheckParametersChanged error.

1 messages · Page 1 of 1 (latest)

wraith sundial
#

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 don't understand how to fix it, even though the animation from the child object is transferred to the parent.

high wing
#

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.

wraith sundial
#

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.

subtle nest
subtle nest
subtle nest
# wraith sundial yes

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

wraith sundial
#

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.

high wing
#

Do all of your characters use the same states? Ex. Walk, Run, Jump, etc.

high wing
#

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.

wraith sundial
#

NetworkAnimator hangs on the player prefab, the regular animator on the selected character is also a prefab.

high wing
#

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.

high wing
wraith sundial
high wing
# wraith sundial

Correct, and then you would set Animator.runtimeAnimatorController through script

#

with each hero's specific controller

wraith sundial
#

There are no errors, but the animation does not work.

wraith sundial
#

Where can it be used?

high wing
wraith sundial
#

As you suggest, the animation does not function at all.

high wing
#

Because you did 1 step out of multiple that I suggested.

wraith sundial
#

I don't understand what you're offering me.

high wing
# wraith sundial I don't understand what you're offering me.
  • Put OwnerNetworkAnimator and Animator on your Player prefab.
  • Create one Animator Controller that has all the states your player needs. Drag it in to the Animator on the Player prefab.
  • Create an Animator Override Controller for each hero and their specific animations.
  • Create a script HeroAnimatorData that will be attached to each hero prefab that holds its Animator Override Controller. Should just be a script with a single variable, something like public AnimatorOverrideController heroAnimatorController;
  • In your NetworkPlayerSpawn script you can do var heroAnimationController = selectedCharacterPrefab.GetComponent<HeroAnimatorData>().heroAnimatorController and then do playerController.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.

wraith sundial
#

hey all

#

I just woke up and now I'm going to try what you wrote.

wraith sundial
subtle nest
# wraith sundial

Are you adding or destroying any components on the player at runtime?

wraith sundial
#

when there is only one customer, everything is fine

subtle nest
wraith sundial
subtle nest
#

You might need rebuild

wraith sundial
high wing
wraith sundial
#

It doesn't help. I'm writing about it.

#

Works only on the first player, error on the second

high wing
# wraith sundial

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.

wraith sundial
high wing
#

PlayerController Line 90

wraith sundial
#

Why are you looking at what happens next? If the problem is initially in the first error, which causes the following errors,

high wing
#

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.

wraith sundial
#

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.

high wing
#

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.

high wing
wraith sundial
#

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.

high wing
#

Yours is not.

#

You're adding it at runtime.

wraith sundial
#

What if I add them in advance and simply disable them? And enable them if the player selects that character?

high wing
#

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.

wraith sundial
#

I have 20 characters.

high wing
#

Yeah. That may be problematic.

subtle nest
#

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

high wing
#

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.

wraith sundial
high wing
# wraith sundial

You'd have to have them all enabled by default, disable them after the player spawns and keep the selected one enabled.

subtle nest
#

If they have network behaviors on them then they would need to be enabled at spawn. You can disable the renderer on them

wraith sundial
#

I still get an error even if they are all enabled and then disabled.

subtle nest
wraith sundial
#

For some reason, the second player's prefabs won't turn off.

wraith sundial
#

In general, I don't understand how to disable them for other players.

subtle nest
wraith sundial
#

I'm already doing that.

subtle nest
# wraith sundial

This is a singleton. the network variable here will be the same for all clients

wraith sundial
wraith sundial
#

Did I really beat it after a month? 😄

#

Thank you all.

high wing
#

👏