- Home /
Question by
CJMADDOG%)% · Feb 01, 2015 at 05:29 PM ·
animationfinish
Stop an animation after its finished?
I am creating a very simple script that plays the animations of my weapon, however when I am holding down the left mouse button I want the animation to loop and when I release the button I want the gun to finish playing the animation before it stops instead of just stopping halfway through the animation. This is the code if it helps:
var shooting : boolean = false;
function Start ()
{
animation.Play("draw", PlayMode.StopAll);
}
function Update ()
{
if(Input.GetButtonDown("Fire1"))
{
animation["shoot"].speed = 3.0;
animation.Play("shoot");
shooting = true;
}
if(Input.GetButtonUp("Fire1"))
{
animation.Stop("shoot");
shooting = false;
}
}
Comment
Your answer
Follow this Question
Related Questions
Check animator animation finished? 1 Answer
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers