- Home /
animation play on click
Hello, I am totally newbie in C# scripting ( self-learn on some basic ), so i want to play an animation on click.
Example: I have a landing gear model with 2 animation clips with it ( retract and release );
And i have created an animator with a controller ( namely wheel );
I want to script so that when i walk in front of the landing gear ( i have make a collider );
and upon pressing a key, the wheel will retract, and once i press one more time, other animation clip will be played...it will play alternatively whenever i press on same key.
p/s: What should i do to the animator controller in the animator panel in this case. really grateful to anyone who can stop by and teach me T_T..
Answer by G4merSylver · Dec 23, 2015 at 01:17 PM
First, Have this Animation Documentation page.
I would just create an OnTriggerStay option and an If(input.getKey()){// Play Animation}. Note that you perhaps would need to create an Iterator Coroutine that would keep playing the animation, I think there should be something like animation.length.
Hi, really appreciate your answer. I have try to do some scripting but i cant make the thing to stop at its position after the first animation. ( meaning the thing will just pop back to its original position ) So how can i fixed that? the photo i attached is my script..