- Home /
 
character animation and movement
well heres the deal,, I want my character move as well as the animation to be played. I tried this code but it seems there is a problem function Update () {
  if( Input.GetMouseButtonDown(0) )
  {
       animation.Play( "walk_cycle" );
  }
 
               }
all I want to do is that, when i press "W", my character will move forward and the animation "walk_cycle" will be played.
also, with animation thing, shoud I export my game character to .fbx with all its animation in it? or should I create one .fbx file in each animation? I am kinda confused with this thing.
Answer by ByteSheep · Dec 06, 2011 at 06:05 PM
Try:
    var MoveSpeed : float = 5.0;
     
         if(Input.GetButtonDown("W"))
         {
         transform.position += transform.forward * MoveSpeed * Time.deltaTime;
         animation.Play( "walk_cycle" );
         }
 
               You will then -if you haven't already- have to define "W" in your Input manager (Edit>Project Settings>Input).
This is just a simple way of making your player go forwards - there are plenty of other ways to consider.. Concerning animations - are they showing up in the animations component of your player?
Your answer