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! Your search result can be found below. Plus, we offer support via these channels:

Try Our

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

Join Us
on Discord

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

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.

How to Synchronize PhotonAnimatorView for dynamically added animator and animation controller?

2020-09-20 04:45:55

I add the animator and animation controller for the animator dynamically in the game and it is done for size optimization that way.
Now I am converting my existing games to multiplayer setup.I have added a code that should have synchronized over the network but I dont see the animation controller for the other player added.

I dont see the animation controller added for the other synchronized player for the above code, also I see the error "Animator doesnt have layers setup to synchronize" and "Animators doesn't have any parameters setup for synchronize" I see both the for loops for layer and parameter is been executed but I still see the message in the editor more over I dont see the animationcontroller updating.
What am I missing here?


2020-09-22 14:27:48

If you're instantiating these things dynamically, are you instantiating them with the Photon Instantiate or the Unity Instantiate?

2020-09-25 10:22:34

I have a ResourceLoader that is inherited from IPunPrefabPool, which then lets me create the new PrefabPool object and then let me Instantiate the object using PhotonNetwork.Instantiate.

I am using this setup as I am loading the prefab from assetbundle

2020-10-20 13:16:55

I am not fully following the problem, but at a glance you are up against how animator syncs have to operate. There are details about the Animator that can only be extracted in the Editor, and can't be extracted at runtime. Trying to add Animators dynamically and synchronize them is going to be a long hard road.

2020-10-21 08:49:43

Via mail you added:

This is done to reduce the size of our AssetBundles as we have many characters for male, female and child and they share their respective animatorcontrollers, to optimise the size and download time for assetbundles we separate the animatorcontrollers from the characters and add it on runtime.

Due to how the engine and animation sync works, it's best to have the animator on the prefab. As a workaround, maybe you can create a prefab that's flexible to use different skins? This can be done in OnPhotonInstantiate, using the photonView.InstantiationData. This data is set via the last parameter of PhotonNetwork.Instantiate().

2020-10-21 19:19:21

Thanks for the response, Will try to follow this and see how we can get this suggestion to work. Will drop the message on how it works for us.

Thanks again

2020-11-25 10:42:09

This is update for my current approach
We cant move away from dynamically instantiating our Prefab and AnimationControllers, as we have the system which has been working and have been working great in terms of space and size of our assetbundles.

So to get around with the issue of animationcontroller being part of the prefab, what I do currently is create the skeleton for the avatar with photonAnimatorView and AnimationController before I create an instance of it, I see it is set up properly without any console error, I want to know if this approach is in right direction.

2020-11-25 14:46:44

As long as the Editor Inspector code can run once on the prefab, it will be fine.
Again: The PhotonAnimatorView requires some in-Editor setup to work at runtime.

You can come up with your own CustomAnimatorView, if that makes your life easier but the provided one, does not work without initial setup in the Editor.

2020-11-25 14:48:37

In my experience in writing the animator sync for SimpleNetworkSync, it has to be added before build/runtime. The information scraped out of the Animation Controller requires editor only tools. Names are all reduced to hashes at runtime. You might be able to write your own Animator sync, but it is a bit of a learning curve.

What you are suggesting sounds like you are still trying to add the PhotonAnimatorView at runtime, and I am pretty sure that will fail. Worth a shot though. I am not sure who wrote that component, but it likely uses the same editor only methods as mine and others. In which case it will fail.

2020-11-27 18:50:13

help help

Back to top