- Home /
Only one Instance of Animator is affected by parameter changes
I've created a prefab of my character's hands and I'm using an Animator to play animations based on the state. Unfortunately only one of the instances of the Animator is being affected by the parameter changes I'm making in code. I've tried linking the prefab directly to the class I'm using, but that doesn't affect either of the instances.
What I've gathered is that I must just be referencing a specific instance of my Animator, and therefore only that instance is being controlled, but I'm unsure how to go about changing a parameter in all of the instances of the same Animator in a scene.
Here's the code I'm using to access the Animator parameters:
m_gloveAnimator.SetFloat("PlayerSpeed", m_rigidbody.velocity.magnitude);
Answer by premium123 · Feb 12, 2018 at 02:51 PM
It has no effect on an instance if you change the prefab after Instantiate(). Maybe you should make a script like an manager where are all animators get stored in a list or something. When you want to change a parameter you have to iterate trough them and call the function on every single instance.
What's weird to me, is that if I change the parameter in the Animator Controller in my Assets in the editor, it does affect all of the instances. I assumed that, since I can do this in the editor, I should be able to do it easily in script. However I can't assign that Animator Controller to the script, unless I assign it to a RuntimeAnimatorController, but I can't use that RuntimeAnimatorController to affect parameters.
I was really hoping I wouldn't have to collect all the instances and iterate through them, but I guess if I have to, I have to.
Your answer
![](https://koobas.hobune.stream/wayback/20220612152443im_/https://answers.unity.com/themes/thub/images/avi.jpg)