Make the Character Controller jump to the side

Hi all, how would I go about adding a sideways jump to the FPSWalker script? For example, dodging to the left or right to avoid a collision. I've attempted it with the following but just get vertical jumping. Thanks.

[EDIT] Thanks to Steve pointing out that the FPSWalker script already does most of what I want! I am very forgetful sometimes.

I've gone back to that script with the addition of a boolean so that the player character can only dodge while fighting. There's still the issue of turning though, since the wolf will need to be able to turn to face the target (we're not using the mouse for turning, only orbiting the PC). It would be nice if the player character could rotate while on the ground, but when pressing the jump button and left/right, he jumps to the side without any rotation. If anyone has any ideas how I can amend the following script to accomodate that I'd be grateful.

if (grounded) {
        // We are grounded, so recalculate movedirection directly from axes
        if(isFighting){
            moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        } else {
            moveDirection = new Vector3(0, 0, Input.GetAxis("Vertical"));
            transform.Rotate(0,Input.GetAxis("Horizontal") * rotateSpeed * Time.deltaTime, 0);
        }

        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= currentSpeed;

        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;

    }

It should take one simple adjustment to your script. Move the rotation down to where you check the jump. I checked it in my sandbox project and it appears to behave correctly.

[EDIT] Fixed the code to restore the rotation block while fighting. That adds an extra boolean check.

function FixedUpdate() {

if (grounded) {

    var inputH : float = Input.GetAxis("Horizontal");
    var inputV : float = Input.GetAxis("Vertical");

    // We are grounded, so recalculate movedirection directly from axes
    if (isFighting) {
        moveDirection = new Vector3(inputH, 0, inputV);
    } else {
        // Don't rotate here.
        moveDirection = new Vector3(0, 0, inputV);
    }
    moveDirection = transform.TransformDirection(moveDirection);
    moveDirection *= speed;

    if (Input.GetButton ("Jump")) {
        moveDirection.y = jumpSpeed;
    } else {
        if (!isFighting) {
            // Only rotate when not jumping.
            transform.Rotate(0, inputH * rotateSpeed * Time.deltaTime, 0);
        }
    }
}

// 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;

}

There is one weakness to the way you are doing it. If the character is rapidly bouncing up and down off the ground, such as can occur on rough ground, the rotation will be a bit jittery.

If that is a problem for you, you may want to mimic the smooth rotation method used by the standard MouseLook Script. I.e. Create a private method that implements the the rotation smoothly, and call the method in place of the direct call to "transform.Rotate(0, inputH * rotateSpeed * Time.deltaTime, 0);".