public Animation[] attacks; //Put attack animations here
void Start () {
Random.seed = System.DateTime.Now.Ticks; //Just for full randomization
}
void Attack () {
Animation.Play(attacks[Random.Range(0,Mathf.RoundToInt(attacks.Length));
}
US:
var attacks : Animation[]; //Put attack animations here
function Start () {
Random.seed = System.DateTime.Now.Ticks; //Just for full randomization
}
function Attack () {
Animation.Play(attacks[Random.Range(0,Mathf.RoundToInt(attacks.Length));
}
I don’t have time to test these codes, but if any error occur, please write a comment about it
public Animation animate;
public Animation[] animateClips;
and,
animate = GetComponent<Animation>();
and then,
animate.Play(animateClips[Random.Range(0, Mathf.RoundToInt(animateClips.Length))]);
then I got this error,
Assets/Script/EnemyAnimControl.cs(52,17): error CS1502: The best overloaded method match for `UnityEngine.Animation.Play(UnityEngine.PlayMode)’ has some invalid arguments
public Animation animate;
public AnimationClip[] animateclips;
and,
animate = GetComponent<Animation>();
and then,
animate.Play(animateclips[Random.Range(0, Mathf.RoundToInt(animateclips.Length))].name);
because animation.play(String name) use string parameter