Sign up ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
Can you screencap the hierarchy where the relevant GameObject is and whatever the inspector is showing with this player selected? – Gunther Fox Dec 22 '15 at 22:14
    
Is the animation controller that you are attaching the one with the animations in it? I have had this issue before when adding an animation controller it just creates an empty on instead. If that is the case simply copy your animations into that controller that is attached to your game object. – Shaun Dec 23 '15 at 7:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.