Random animation

How right? Unity reports an error: “The name ‘animation’ dosnt exist in the current context”

using UnityEngine;

namespace zm_ra
{
class zm_ra
{
static void Main() 
{          
int variable = UnityEngine.Random.Range(0, 1);
switch(variable)
{
case 0:
{
animation.CrossFade("zm_anim_run1");
break;
}
case 1:
{
animation.CrossFade("zm_anim_idle1");
break;
} 
}
}
}
}

(C#)

Your class needs to extend MonoBehaviour. And you need to attach an Animation component to your object.

Hey Tomo,

did you get it to work after extending Monobehaviour and attaching an Animation component? I am also trying to alternate between idle animations but my character will only run through one of them. my code looks just like the one you posted.

Thanks in advance…