Animations not working


Hey guys, I am working on a post apocalyptic zombie shooter I am right now trying to make the Animations play, I have looked at all tutorials on youtube and unity lessons, but they don’t work, i have attached the animation to the gun but for some rason it dosent work, here is my script:

#pragma strict
var Bullet : Rigidbody;
var Spawn : Transform;
var Bullet_Speed : float = 1000;
function Start () {

}

function Update () {
if(Input.GetButtonDown("Fire1"))
{
Fire();
}
}
function Fire()
{
var Bullet1 : Rigidbody = Instantiate(Bullet, Spawn.position, Spawn.rotation);
Bullet1.AddForce(transform.forward * -Bullet_Speed);
audio.Play();
animation.Play(); // Animation not working here :(


}

Do you have a component on the object called Animation, or Animator?
You are using the “animation” calls which are used for the old animation system, but if your object has an “Animator” component then that is for the new animation system.
So you would be mixing the two systems.
Check the actual unity tutorials on mechanim instead. Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn

I would make sure that you can play the animation in the inspector. Also check if it is looping or not. If it isn’t looping I know I have had some problems with my animations not playing before.

@wesleywh yeh, they play in the inspector alright but other then that it dosent work. :frowning: