Hi everyone, I've only been playing with Unity for a few weeks, so I'm sorry if this is a stupid question. I am having trouble with the standard FPSWalker class. When looking up and walking forward, (or backwards looking down) the camera bounces. The script moves the camera in the direction it is pointing with a y component, causing it to leave the ground shortly, or conversely, slow to a crawl when point at the ground. This makes no sense to me, because the following line should give the moveDirection only x and z values: Code (csharp): moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); It seems to me like there should be really simple solution for this, but I don't see it. Thanks in advance for any advice.
Hi, welcome to the forum! Are you sure the value of moveDirection isn't being modified elsewhere? Perhaps you could post the whole script?
Here's the whole script. I don't think I've modified it at all, it's the original that came with Unity: Code (csharp): var speed = 6.0; var jumpSpeed = 8.0; var gravity = 10.0; private var moveDirection = Vector3.zero; private var grounded : boolean = false; function FixedUpdate() { if (grounded) { // We are grounded, so recalculate movedirection directly from axes moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= speed; if (Input.GetButton ("Jump")) { moveDirection.y = jumpSpeed; } } // Apply gravity moveDirection.y -= gravity * Time.deltaTime; // Move the controller var controller : CharacterController = GetComponent(CharacterController); var flags = controller.Move(moveDirection * Time.deltaTime); grounded = (flags CollisionFlags.CollidedBelow) != 0; } @script RequireComponent(CharacterController) Thanks for the response!