- Home /
Stop animations while not touching anything? (including terrain)
Hi, this might seem a simple question, but I'm trying to figure a way to stop First Person Controller animations when it is not touching the terrain or anything (basically just in the air.) How could I do this? (hoping for a small piece of code, but anything will do for now)
Any help is appreciated.
Thanks
Answer by AlejandroGorgal · Nov 27, 2013 at 06:14 PM
If you are using a character controller then you could simply use the "isGrounded" statement to force it to either play a falling animation or stop all anims altogether.
For example:
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded)
// All the stuff your character does when it's on the ground.
}
else
{
animation.CrossFade("Falling");
}
More info: http://docs.unity3d.com/Documentation/ScriptReference/CharacterController-isGrounded.html
Your answer
Follow this Question
Related Questions
Animation of terrain causes drastic performance drop (fps) 0 Answers
Stop one animation while another plays 2 Answers
How do I stop sprite animation on last frame? 2 Answers
Can't stop animation 2 Answers