3D multiplayer game - model animator sync not syncing on network

I have been using needle engine for creating a multiplayer game. Ive some issues syncing animator animations on my downloaded 3d model instance. Need help on how to get animator syncs!

I have tried PlayerState.IsLocalPlayer() but its not working for my downloaded model object.

Need help

Original Post on Discord

by user 389863047159873540

Hey :wave: So you download a model from an external URL? Or what do you mean by “my downloaded 3d model instance”?

Yes external url

by user 389863047159873540

@marcel :cactus: : Need help with this

by user 389863047159873540

Hi @narendra.chaudhary
can you describe what you’re doing right now and what your goal is? How do you currently sync animations and which models are you downloading from where? Have those models been exported with any of our integrations?


I am trying to download a readyplayerme avatar model (public url) and animate it using an existing controller. I am able to download and see the model but when animator and syncanimator is attached on it, it does not animate.

I have seen the sample animator code and doing the same, but what I have observed is the animator component is reparented but it does not lose the references of the original animator, the new model stays in T-pose but the old model is seen animating. (Img attached in attachment)

  • white model is static model that is in prefab that is spawned when user joins room
  • black model - downloaded model and in T-pose.

by user 389863047159873540

Above Code Snippet:

let go = this.currentObject; // downloaded model
let animator = this.mainanimator; // animator reference of a static model

// SyncAnimator is custom class for animation syncing across network
if (animator) {
animator.enabled = false;
const sync = GameObject.getComponent(animator.gameObject, SyncAnimator); 

let parent = animator.gameObject.parent;
if (!parent) {
  console.log("parent to animator is null, animator is" + animator.gameObject.name);
go.name = animator.gameObject.name; // renaming the object name as we noticed that animations do not work if the object name was different,
// some error on nodes.<object name> is null

// move data over
var animatorInstance = GameObject.addComponent(go, animator) as Animator; // this statement just reparents the component to new object 

if (animator) {
  animator.enabled = true;
  console.log("new animator ", animator, animator.gameObject.parent);
} else {
  console.warn("animatorInstance on downloaded model found null or undefined");

// adding Sync Animator Component to sync player animations on network...
let syncAnimatorInstance = GameObject.addComponent(go, sync!) as SyncAnimator;

if (syncAnimatorInstance) {
  syncAnimatorInstance.currentSyncedTransform = this.currentSyncedTransform!;
} else {
  console.warn("syncAnimatorInstance on downloaded model found null or undefined");

by user 389863047159873540

Hey :wave:

1. You are trying to migrate a component

  • you have to call GameObject.removeComponent ideally before calling GameObject.addComponent. Otherwise the component will be on both of the objects
  • It would be better to not migrate it at all, but rather to create everything from scratch (GameObject.addNewComponent). Create a new Animator component, add it to the object, set the controller
  • If that doesn’t work, then try calling the initializeRuntimeAnimatorController

2. SyncAnimator

  • Currently it is limited that the SyncAnimator can’t change during runtime, so migrating it is not an option.
  • You can add it on the object when it is spawned, the object just needs to have an Animator attached

Hi, would you mind putting your code into a code block? Otherwise it’s very hard to read. See https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-#h_01GY0DAKGXDEHE263BCAYEGFJA
Thank you! :slightly_smiling_face:

Thanks for the suggestion. I’ve edited the same in above code snippet. Hope its more readable now. Looking forward for your review.

by user 389863047159873540

Are there remaining issues or does the code work for you now?

I’ve made changes as suggested. It worked. Will test more and share my review on it later. Thank you.:+1:t2:

by user 389863047159873540

Excellent! Yes, please keep us posted, I think it would be nice to have a ReadyPlayerMe sample, so if you would like to contribute that I’m all ears :+1: