I have a 3d model of a gun and I added it in the scene. Within the model there is an animation “Take 001” so i created a js script:
function Start () {
}
function Update () {
if(Input.GetButtonDown("Fire1")){
animation.Play();
}
}
and I added it to the model. But when (in game) I press the left mouse button the animation doesn’t start. I also tried to replace “animation.Play();” with “animation.Play(“Take 001”);” but nothing has changed.
You should always put the name of the animation in “animation.Play(“Take 001”)”. So I think you should change the animation.Play(); into → transform.animation.Play(“Take 001”);
Hope this helps
p.s. I don’t know if TRANSFORM infront of animation will work. So, if it doesn’t work after putting transform.animation.Play(“Take 001”); then delete transform from it.