X , Z only... PlayerMovement

hey how to make my Player only can move in X and Z axis, not at diagonal xz… ??

and use Character Controller

thanks

[Unity - Scripting API: CharacterController.SimpleMove][1]

[1]:
use Vector3.forward for z axis
and Vector3.right for x axis

don´t use the reference way:

moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

Better use your own one with Key conditions for straight movement. Like:

if(Input.GetAxis("Horizontal") != 0){
	moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, 0);
}
else if(Input.GetAxis("Vertical") != 0){
	moveDirection = new Vector3(0, 0, Input.GetAxis("Vertical"));
}

(written via iPhone) Hope it helps :slight_smile: