- Home /
 
 
               Question by 
               ktan · Apr 11, 2013 at 04:01 PM · 
                rotationcharactermovetranslation  
              
 
              First person controller not moving properly after rotation
I have a First Person Controller that I move as follows:
 GameObject Person=GameObject.Find ("First Person Controller");
 if(GUI.RepeatButton(new Rect(moveForward), "")){
     Vector3 fwd = Person.transform.TransformDirection(Vector3.forward);
     Person.transform.Translate(fwd*timeDelta*10);
 
 }
         
 if(GUI.RepeatButton(new Rect(moveBackward), "")){
             
     Vector3 fwd = Person.transform.TransformDirection(Vector3.back);
     Person.transform.Translate(fwd*10*timeDelta);
 }
         
 if(GUI.RepeatButton(new Rect(turnLeft), "")){
             
     Person.transform.Rotate(0,-20*timeDelta,0);
 }
         
 if(GUI.RepeatButton(new Rect(turnRight), "")){
             
     Person.transform.Rotate(0,20*timeDelta,0);
 }
 
               The problem is if I turn left and then move forward, the object moves as if I never turned left i.e all rotations are lost when I select move forward or move backward. Any help?
               Comment
              
 
               
              try Person.transform.forward in place of Vector3.forward and -Person.transform.forward in place of Vector3.back.
Answer by ktan · Apr 16, 2013 at 02:47 PM
I fixed it by replacing
 Person.transform.Translate(fwd*timeDelta*10);
 
               with
 Person.transform.Translate(fwd*timeDelta*10,Space.World);
 
              Your answer