- Home /
Using one animation on multiple objects?
In my scene, I have several different panels with buttons on them. The buttons are all already there, they're all duplicates of eachother (excluding color), and there's maybe 30 in total. I made an animation for one of the buttons so when I click the mouse, the button goes down, and then back up again. The problem is, I want all of these buttons to have the exact same animation, but I don't see a way to easily just transplant the animation from one to all 30. Is there a way to do that?
Answer by agray427 · Jan 15, 2018 at 05:18 PM
By making an animation controller and providing that one controller to all of them? That should work. The animation is made to the transform or something they all share, so that same value will be changed in the same way that it is on the other panels. You will need to have a script that interacts with the controller, telling it when to move and stuff, but that is rather simple. Plenty of tutorials online!
Thank you for the suggestion! I do have one question; if I were to set this up with a raycast trigger, would I be able to only activate one at a time? i.e. I look at one of the buttons, click, and only have that button animate?
Yes, that is correct. An animator controller is a finite state machine that contains all of the animations (states) that the finite state machine will use. Then it uses parameters, conditions, and transitions to function as a finite state machine should. But yes, it acts only on the object it is attached to when the condition of that object is met. If you are wanting all of your animations to occur at the same time, you will need to set up a delegate and event and have all of the objects listen for that event and set their respective animator controllers to respond to it.