Hey all. I’m trying to script a function in which an animation plays on click of a gameobject. However, instead of naming the animation in the parenthesis, I want to be able to declare it as a variable, so I can use the script for multiple gameobjects so I don’t have many scripts for different animations. However, I’m getting an error. Any help?
Error: Assets/Scripting/Click to move.js(7,17): BCE0004: Ambiguous reference ‘animation’: Click to move.animation, UnityEngine.Component.animation.
var animation : Animation;
function Update() {
if(Input.GetMouseButtonDown(0))
{
animation = AnimationClip;
animation.Play();
}
}