charactercontroller.move() dont work right

var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;

private var moveDirection : Vector3 = Vector3.zero;

function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = 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
controller.Move(moveDirection * Time.deltaTime);
}

This code dont work as i should for me, the positive vertical value dont work right.
Anyone had the same problem?

This code is direct from the unity script reference manual.

var speed : float = 7.0;
var jumpSpeed : float = 4.0;
var gravity : float = 5.0;
var rotateSpeed : float = 3.0;

private var moveDirection : Vector3 = Vector3.zero;

function Update() {
var controller : CharacterController = GetComponent(CharacterController);

transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);

if (controller.isGrounded) {

moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;

if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}

moveDirection.y -= gravity * Time.deltaTime;

controller.Move(moveDirection * Time.deltaTime);
}

@script RequireComponent(CharacterController)

The character doesn’t move or the character moves in strange ways?

Make sure that you don’t have any joystick turned on the computer!

Make sure that you applied the script on the character! XD (Sometimes happens to me)

And tag the character as a player too :stuck_out_tongue:

This is solved, this code is corrent!
Problem was i parented in stuff with the character that had colliders ._.