Hi all,
I have a problem with the animator at my NPCs. It works well is only one character at scene, but when i am placing a few same objects from prefab animatin changes only at one of them. What am i doing wrong?
How exactly are you creating the characters? Are you sure they are all playing an animation?
I create them using Instantiate() after clicking a button. And the animation plays on all character but changes only at one of them, at another charecters of this type playing a default animation of controller in any cases.
What do you mean by “changes only at one of them”? Do you mean the transforms are not affected or Animator does not change states? How are you checking that it is playing the animation on all characters? How are you telling them to change states?
It’s difficult to help when all I know, is that you’re trying to play animations on multiple characters and something is going wrong.
In my script idle animation changes to another animation after I click the character. I am using a OnMouse() procedure to track click on current object. After it I change the Animator Controller bool parameter by GetComponent().SetBool() and after it animation changes. It worked well and I saved my character as prefab and cloned it on scene. But when I click characters, animation on original object(without numbers like (1),(2)…) changes but on another objects is playing default “idle” animation.
Only thing I can think of is the SetBool not being called for the clones. If you haven’t already, make sure this is not the case by printing out the name of the GameObject right before you call Animator.SetBool().
The animators themselves should run for multiple characters just fine.
Thank you very much. After I deleted the Animator variable in my script and replcaced all code with it just to GetComponent.Animator() all started working well. I have no idea why can’t i write the Animator to the variable and after use it to change the parameters.