I have created the walking and idle animation for my fps player. I've added a JavaScript script to access it, but when I run it and press button(w), it stops and says that the animation is not attached to the object.
When I drag the walking/idle animation and drop to that object, it creates an animation controller. Again I run it, still same error. I can't find where to attach the animation
Here's my script:
function Update ()
{
if(Input.GetKeyDown("w"))
{
GetComponent.<Animation>().Play("walk_anim2", PlayMode.StopAll);
}
if(Input.GetKeyUp("w"))
{
GetComponent.<Animation>().Play("idle_anim2", PlayMode.StopAll);
}
}
Where do I need to attach the animation?