Add NetworkMecanimAnimator at runtime

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Fusion.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Add NetworkMecanimAnimator at runtime

LiamVisionary
2022-08-13 18:11:10

Is there some special set of steps that needs to be followed to get the network mecanim animator to work when added to an object at runtime? I've done the following:

  1. Instantiate player model and parent to player.

  2. Add animator to model

  3. Add network object to model

  4. Add NetworkMecanimAnimator to model

, but it seems there is a missing pointer or something as I get an error when adding the animator, and another when trying to trigger animations.

In the inspector, I see the NMA auto-retrieves the correct unity animator, so I'm not sure why it's throwing errors.

Comments

Luke_Sta
2022-08-13 19:26:31

NetworkMecanimAnimator is a NetworkBehaviour. Fusion does not support adding NetworkBehaviours to objects at runtime.

LiamVisionary
2022-08-14 18:16:50

Luke_Sta 2022-08-13T19:26:31+00:00

NetworkMecanimAnimator is a NetworkBehaviour. Fusion does not support adding NetworkBehaviours to objects at runtime.

Noted! I've refactored with that in mind and now I'm in the clear. Thank you :)

zibizz1
2022-08-16 18:25:29

@Luke_Sta Can we at least replace the animator at runtime in NetworkMecanimAnimator?

Luke_Sta
2022-08-17 08:04:32

zibizz1 2022-08-16T18:25:29+00:00

@Luke_Sta Can we at least replace the animator at runtime in NetworkMecanimAnimator?

I think that should work but I have never tried it. I'd recommend to replace the animator in Spawn immediately when the object is spawned.

Back to top