I want an animation to play on an object when I press this a button. How close was I? (still Learning scripting)
var Clip : Animation;
function Update (){
if(Input.GetButtonDown("Fire1")){
animation.PlayOneShot(Clip);
Animation.Play();
}
}
1 Answer
1
Fairly close. Some minor changes and it will work:
var Clip : AnimationClip; //the AnimationClip you want to play
function Update (){
if(Input.GetButtonDown("Fire1")){
animation.Play(Clip.name);
}
}
This assumes that the animation component is on the gameobject that has this script attached, and has a reference to the same animationclip.
Is 'Fire1" set-up as an input key under Project Settings/Input?
– Julian-Glenn