Get animation work

I want to make “shoot” animation being played each time only after bullet shot out. Here’s my script:

private var _animation : Animation;

var Bullet : Transform;

var Speed = 500;

var spawnPoint : Transform;

var Counter = Time.deltaTime;

var RateOfFire = 0.250000;

var target : GameObject;

function Shoot() {

    yield WaitForSeconds(0.1);
     
    Counter += Time.deltaTime;
    if(RateOfFire<Counter){
    var shotRapid = Instantiate(Bullet, spawnPoint.transform.position,
    Quaternion.identity);
    shotRapid.rigidbody.AddForce(transform.forward * Speed);
    Counter=0;
    }
     }

So how can it be achieved? Thanks in advance for your feedback :slight_smile:

Assuming you have an animation named “shoot”:
You could use a Keydown event, add Animation.Play() or Animation.CrossFade to the statement. You COULD just add it to your shoot() function as well, since you’re jumping to it in this example anyway.

function Update()
{
    if(Input.GetMouseButtonDown(0))
    {
        animation.CrossFade("Shoot", .1f);
        Shoot();
    }
}