- Home /
my floating spaceship(charactercontroller) won't move in x direction...
My floating spaceship(Character Controller) won't move in x direction, but it does move in y direction.
And this is a script i am using:
var speed : float = 6.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() { var controller : CharacterController = GetComponent(CharacterController); moveDirection = Vector3(Input.GetAxis("Horizontal"),Input.GetAxis("Vertical"),0); //Debug.Log("Horizontal"); //Debug.Log(Input.GetAxis("Horizontal")); //Debug.Log("Vertical"); //Debug.Log(Input.GetAxis("Vertical")); moveDirection = speed; //Debug.Log(moveDirection); controller.Move(moveDirection Time.deltaTime); }
Also if i use the construct below it moves perfectly along the y and z axis. It seems as only x axis is the problem.
moveDirection = Vector3(0,Input.GetAxis("Vertical"),Input.GetAxis("Horizontal"));
I don't see anything there that'd cause motion in the x direction not to work. Are there any external constraints on the character controller or its position?
Answer by mpupovac · Jan 19, 2011 at 10:23 PM
I finally figured out what was the problem. My Character Controller object was a cube which had both cube collider and Character Controllers capsule collider components. So the Character Controllers capsule collider was constrained by the cube collider on the x axis. After i removed the cube collider from the object everything worked just fine.
Your answer
