Bouncing character like on a pogo stick

I am just using a basic player movement script that I found online, but what I am looking to do is modify this script so the character is constantly jumping. As if the character were bouncing on a pogo stick. I was thinking of just adding a loop that constantly press my jump button, but I don’t think that’s very efficient.

Any ideas? (below is my code)

var speed : float = 6.0;

var jumpSpeed : float = 8.0;

var gravity : float = 20.0;

private var moveDirection : Vector3 =;

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,
    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);


After a good nights sleep I came back and just removed the ‘moveDirection.y = jumpSpeed;’ outside of the if statement, that way when the conteroller.isGrounded it will jump automatically.