Question by
LordMix · Oct 14, 2015 at 09:42 AM ·
javascriptanimations
Javascript Animation Playing Error
#pragma strict
var Anim = gameObject.GetComponent("Animation");
function Update () {
if (Input.GetMouseButtonDown(0))
{
Anim.Play("Shoot");
}
}
For some reason, this line of code will not work. I keep getting the error: "Assets/Recoil.js(8,6): BCE0019: 'Play' is not a member of 'UnityEngine.Component'."
I have tried wording it differently, and noone else seems to have this problem. The Animation component IS there, it is just saying Play is not a function for the animation.
Comment
Best Answer
Answer by Graham-Dunnett · Oct 14, 2015 at 09:44 AM
Specify a type for Anim, which needs to be Animation.
Your answer
![](https://koobas.hobune.stream/wayback/20220612041223im_/https://answers.unity.com/themes/thub/images/avi.jpg)