i have two animations for a gameobject. one when it stands still and a blended one when it moves. when the object stands still again it should again play only the firs animation. how can i make an animation stop but still play until the end? if i write animation.Stop it just stops at this frame in some strange position. i want the animation to play until the end and stop it then.
thank you!!
Make sure you have the correct wrap mode for the specific animation. in a situation like this wrapmode.once should work fine but you may need clampforever. Also set a boolean to determine if the animation is playing. If it is then don’t stop the animation while it’s playing. if it is not playing then stop the animation. you can use the built in boolean (animation.isPlaying) but I just write my own for this kind of thing. if you still have trouble then post your code
hi! thank you very much for your answer. the problem is, that i need both animations in loop, because they should run the whole time when used.
is there a solution to solve the problem even if the animations are on loop?
the animation that should run even if the player is standing plays automatically when pressed play.
here is my code:
private var torqueforce : float = 150.0;
private var forwardforce : float = 100.0;
var stand : boolean = true;
function FixedUpdate ()
{
if (Input.GetKey(KeyCode.LeftArrow))
{
rigidbody.AddRelativeTorque (Vector3(0, 0, -torqueforce));
animation.Blend("moveanim");
stand = false;
}
else
{
stand = true;
}
if (Input.GetKey(KeyCode.RightArrow))
{
rigidbody.AddRelativeTorque (Vector3(0, 0, torqueforce));
animation.Blend("moveanim");
stand = false;
}
if (Input.GetKey(KeyCode.UpArrow))
{
rigidbody.AddRelativeForce (Vector3(0, -forwardforce, 0));
animation.Blend("moveanim");
stand = false;
}
if (stand)
{
animation.Stop("moveanim");
}
}