I'm new on unity and I developed a script to move a player cube:
var moveSpeed = 5.0f;
var x = moveSpeed * Input.GetAxis("Horizontal") * Time.deltaTime;
var z = moveSpeed * Input.GetAxis("Vertical") * Time.deltaTime;
transform.Translate(
x,
0f,
z
);
This works fine, the cube moves around the plane.
Then I wanted to make the cube rotate to face the movement, I mean, if the cube is moving to the right, face the right, etc.
the problem is when I change the transform.rotation with the direction position, there is a strange behaviour.
The movement is like WASD (the camera doesn't rotate, but I want to use Input.GetAxis("Horizontal"))
Any idea?
Thanks