- Home /
2d Movement Messes up when cube is rotatated
Hello unity members,
I am in the process of making a 2d game. I have made a small script for movement
 #pragma strict
 var speed : float = 20;
 function Start () {
 
 
 }
 
 function Update () {
 if(Input.GetKey("d")) {
  transform.Translate(Vector3(speed,0,0) * Time.deltaTime);
 //transform.Translate(Vector3.right * Time.deltaTime * 10);
 }
 if(Input.GetKey("a")) {
 transform.Translate(Vector3(-speed,0,0) * Time.deltaTime);
 //transform.Translate(Vector3.left * Time.deltaTime * 10);
 }
 }
The problem that im having is when the cube flips over in game and I hit "D", the cube goes downwards instead of to the left because of the rotation. How can I change this so the movement stays the same but the cube can still rotate.
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                