jump

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

private var moveDirection = Vector3.zero;

function FixedUpdate() {
    var controller : CharacterController = GetComponent(CharacterController);
    if (controller.isGrounded) {
        moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
                                speed-5);
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
        
        if (Input.GetButton ("Jump")) {
            moveDirection.y = jumpSpeed;                
         }
    }

   
    moveDirection.y -= gravity * Time.deltaTime;
    
   
    controller.Move(moveDirection * Time.deltaTime);
}

How do I do that I can move when I am jumping I tried with Input.GetKey and transform.TransformDirection but that didn’t work

Just remove the move direction stuff out of the If grounded if statment and it should work. just put the move direction some other place in the FixedUpdate function. :smile:

Here is a cool FPSWalker script with lots of features. I added flying/Levitation to. 8)

http://forum.unity3d.com/viewtopic.php?t=52861&highlight=quick+job

if i do that the character falls slowy. so i adjust the gravity but then the character can’t jump that high anymore. how do i fix this?

Did i not mention that the walker script at the link i gave you lets you move while jumping. Even if you dont want to use it u can see how it was done in that script to get some good ideas :smile:
Plus theree are two other scripts that are very usefullllll :idea: :smile: