Jumping script...

Hello. I modified an example from the script reference to create a very simple press-space-to-jump script. I want to modify it again to make it work like a “normal” platformer (holding down the space button longer makes your character jump higher). What should I do first? Thanks

    var jumpSpeed : float;
    var gravity : float;
    private var moveDirection : Vector3 = Vector3.zero;
    function Update() {
        var controller : CharacterController = GetComponent(CharacterController);
        if (controller.isGrounded) {
            if (Input.GetButton ("Jump")) {
                moveDirection.y = jumpSpeed;
            }
        }
        moveDirection.y -= gravity * Time.deltaTime;
        controller.Move(moveDirection * Time.deltaTime);
}

it doesn’t work

Unity doesn’t support Javascript anymore. This is from 2013.

You’ll probably want to translate it in to C#.

1 Like