- Home /
Is there a 'Play On Awake' function for animations?
Do animations have a function similar to sounds 'play on awake' function?
If so, how do I turn it off so I can then set the animation to work/start via a script and not just play automatically as soon as the object is instantiated?
???
(edit) I've tried adding an Animation component to the specific object and making sure Play Automatically option is unchecked. This had no affect.
Answer by Chris333 · Jan 18, 2015 at 02:17 PM
Hi,
i don't know if you are using the mecanim state machine or the legacy system.
With the mecanim state machine you could just create 2 states, one for the default state to do nothing and the second one for your animation. If you instantiate the object it would be in the default state. To switch than in the other state and play the animation you could set 2 transitions between these states. One transition for entering from default state to the second state and the other transition from the second state back to the default state. You can than create a parameter and set this parameter in the conditions in the inspector of the transitions. Via script you can than trigger the parameter to be changed and the mecanim system will switch into another state if the condition is met.
This tutorial explains it very well. It's basically for 2D character but he also explains the mecanim system and the components. http://unity3d.com/learn/tutorials/modules/beginner/2d/2d-controllers
There are also these basic tutorials for the animations sytem: http://unity3d.com/learn/tutorials/modules/beginner/animation
Hope it helps.
Your answer
Follow this Question
Related Questions
Rewind/Play animations on demand. 1 Answer
Playing an animation when press left mouse key - Using Orthello JavaScript 1 Answer
problem not playing animation on keyDown 2 Answers
ExecuteInEditMode Component construct "twice" and "reset" custom classes 0 Answers
Play Animation on trigger enter 1 Answer