How to make player jump? (JavaScript)

Okay so I have been trying to make my player able to jump around in the world, but all i can seem to get is him to move X and Y, here is the code I have come up with:
#pragma strict

var speed : float = 3.0;
var rotateSpeed : float = 3.0;

var moveJoystick : Joystick;
var rotateJoystick : Joystick;

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

// Rotate around y - axis
var rotatePos = Input.GetAxis (“Horizontal”) ?
Input.GetAxis (“Horizontal”) : joyStickInput(rotateJoystick);
transform.Rotate(0, rotatePos * rotateSpeed, 0);

// Move forward / backward
var forward = transform.TransformDirection(Vector3.forward);
var movePos = Input.GetAxis (“Vertical”) ?
Input.GetAxis (“Vertical”) : joyStickInput(moveJoystick);
var curSpeed = speed * movePos;
controller.SimpleMove(forward * curSpeed);
}

function joyStickInput (joystick : Joystick) {
var absJoyPos = Vector2 (Mathf.Abs(joystick.position.x),
Mathf.Abs(joystick.position.y));
var xDirection = (joystick.position.x > 0) ? 1 : -1;
var yDirection = (joystick.position.y > 0) ? 1 : -1;
return ( ( absJoyPos.x > absJoyPos.y) ? absJoyPos.x * xDirection : absJoyPos.y * yDirection);
}

@script RequireComponent(CharacterController)

I am only 12 so that is why I cant really get the z movement :stuck_out_tongue:

Hey Jack, while I use C# instead of javascript, looking at your script, there doesn’t seem to be a jumpheight variable. I don’t believe charactercontroller getcomponent should be in the update function either that should be in a start function. Although it is a mobile game, the Penelope tutorial has a jump button on the javascript with an inair multiplier that helps the player jump in other directions. You might want to skim over that. Since you are using a character controller you are going to want to check if you character is grounded as well before jumping. Also when you post to the forums you should format your code to make it easier for people to look at. The option to do so is in the advance section of creating a thread or reply. Just highlight your code and select the # button and it will format your code. Good luck.

Read this :

http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.Move.html

Okay, thanks! I have figured out the jump, and I posted in the wrong code, that is why The variable wasn’t there, thanks for the help on the code and forums!