When I Rotate the GameObject ,I can not use Vector3.right move GameObject in x axis.

horizontalInput = Input.GetAxis(“Horizontal”); verticalInput = Input.GetAxis(“Vertical”); transform.Translate(Vector3.righthorizontalInputspeed*Time.fixedDeltaTime);

This is my player Controller files; I connect to my player If I press a game object will move in the z-axis, by the way, I rotate my game object 90 degrees on the y-axis.

and the weird thing is the original position of the game object is (0,0,0), if I press a to move it, the position will be(-7,0,4)

1 Answer

1

The transform.Translate function has also a second parameter, see Unity - Scripting API: Transform.Translate.

Try transform.Translate(Vector3.righthorizontalInputspeed*Time.fixedDeltaTime, Space.World);

This might solve your problem.

I love you! you solved my problem.