- Home /
Animator parameter changing for only one instance
I have a prefab that gets instantiated 10 times in Start()
. However when I use
anim.SetFloat("parameterName", value);
the parameter only changes for the first clone.
I was thinking of making a list or something that stores the Animators and call the function on all of them individually.
Would that work? If so, how exactly would I go about that? Is there a better solution? Thanks for any advice.
There are a lot of ways that you can do this and yes, list is one of them. A list is less optimized than an array though, but if you are dynamically changing the size of the animators being stored, than a list would be the better option between the 2.
If you only need to set the parameter once, or every once in a while. You could just give these objects a tag and reference them all with FindGameObjectsWithTag(“tagName”);, which is an array that you can loop through and set the value via a for loop.
Another option would to have a script on these objects that starts the animation a certain amount of time after instantiation with a coroutine..
Your answer
Follow this Question
Related Questions
Instantiate a prefab and then add a animator component and controller to the component. 2 Answers
Checking if object intersects? 1 Answer
Updating animator for instantiated/cloned object 2 Answers
Setting the state of instantiated 2d animator 0 Answers
How to spawn GO at non (0,0,0) and have Animator work 0 Answers