How would you go about setting the animation of an ai? For example, running, idle etc. animation.Player(); does not seem to work for me?
Assuming you’re using legacy,
You’ll need to access the animation component and then type:
animation.Play(“animation name”);
Do you only need animation playing part of the script or also AI movement?
function Update(){
animation.Play("AnimationName");
}
And if you are using mecanim just use variable of the type Animator, get the components of Animator on the script. And then just
nameOfAnimatorValue.SetBool/Float…(“nameOfTheVariableOnTheAnimator”,true(bool)/false(bool) or floatnumber(float))
something like this.
animator.SetBool(“Shoot”,true); animador.SetBool(“Shoot”,false);
Don’t do it this way.
This is performance heavy.
You can do it through start.
void Start()
{
animaion[“CLIPNAME”].wrapmode = WrapMode.loop;
animation.play(“ClipNAME”);
}