Prevent Animation From Playing Until Button is Pressed.
I have an animation with keyframes, it begins automatically when the player is initialized.
The animation rotates an object 15 degrees, then rotates it back to 0 degrees.
I want the animation to be stopped at frame zero, until a button tells it to play, then it will play to the next keyframe and stop, again. Basically this will appear as a toggled open/close animation.
It seems like a simple operation, but it is not.
How do I make the animation stop at the keyframes?
How do I get my button to tell the animation to play?
Thank you in advance.
Answer by JefferyWright · Jan 21, 2016 at 07:14 PM
Thanks,
Animation event = no function selected, and no functions available... where do I get these functions?
I know, I have to create a script, isn't it possible to do this without script in Unity? It is such a simple operation.
Is there a list of script functions that will stop a timeline from playing? Where are they located? How do you know what stops a timeline from playing?
Answer by Gabriel-Oliveira-Almeida · Jan 21, 2016 at 06:21 PM
I do not tested . But you can try to use , the animation event . By clicking above the keyframe you can put a animation event script. The script would have to stop the animation and continue only after a certain condition. OR split your animation in two and create a transition between them which corresponds to their condition.
Okay, so I created a total of 4 Animations (which all had to be converted to 'Legacy' for some reason?):
(So the image file uploader does not work in this forum? Or is it just my browser? )
I attached them to my Wings object:
When I run the player, the animation seems to be at the first animation, which is fine.
In the Animator, I have all the Animations on the grid:
I cannot find any information about how to get a GUI button click to cause a Transition between the Animations... any ideas?
Thanks, again.
Answer by tramelson · Sep 22, 2016 at 01:41 PM
Wondering the answer to this as well - if there is a way to play/stop in timeline in a script
Answer by Hanross · Jun 17, 2019 at 02:50 PM
it's very easy the object where animator is attached create script if no script is attached or if any script already attached from where animator is controlled then add this into file public void stopAnim() { animator.stop("clipname"); }