- Home /
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#)
Answer by flaviusxvii · Jun 16, 2011 at 04:05 PM
Your class needs to extend MonoBehaviour. And you need to attach an Animation component to your object.
Answer by EmilioDLC · May 12, 2014 at 02:46 AM
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..
The question was posted almost 3 years ago, I'd be surprised if $$anonymous$$o responds to you.
Your answer

Follow this Question
Related Questions
How to check for a missing class ( error CS0103 ) and act accordingly 3 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
health bar script error 1 Answer
Component Call not recognizing boolean. User error? 1 Answer