- Home /
How I can assign a Keyboard key to my animation
I want to assign a keyboard key to my animation so it can start and end.
I want to animate a 3D model of a robot arm inside Unity, is really simple I have only to rotate the arm in one axis, but I want to control it with the keyboard.
I want it to play the animation when a key is pressed.
Any advice?
Thanks in advance
what do you want to do rotate the arm or do you want it to play an animation when a key is pressed ?
I want it to play the animation when a key is pressed.
Thanks $$anonymous$$C HALO
Answer by Justin Warner · Dec 31, 2010 at 04:05 AM
http://unity3d.com/support/documentation/ScriptReference/Input.html
Check those examples.
Well, you make it check if the player uses a key:
if (Input.GetKeyDown ("space"))
and if it does, it plays that animation:
animation.CrossFade ("NAMEHERE");
When you export the model (Assuming FBX), it should export the animations... You can read those here:
http://unity3d.com/support/documentation/Manual/Character-Animation.html
Hope that further helps you.
Justin, thanks but I forget to say that the robot-arm is a 3d $$anonymous$$odel inside Unity.
I edited with more info... See if that's what you mean =).