How to make my player jump?

i am trying to make my player able to jump and with the script i have at the moment it jumps a little bit when pressed but jumps to the height i have set it to when space is held. this is the script i have.

var playerSpeed  : int;

var playerJump : int;

function Update () {

amtToMove = (playerSpeed * Input.GetAxis("Horizontal")) * Time.deltaTime;

transform.Translate(Vector3.right * amtToMove);

amtToJump = (playerJump * Input.GetAxis("Jump")) * Time.deltaTime;

transform.Translate(Vector3.up * amtToJump);

The easiest way to quickly simulate a jump would be to add a rigidbody to your object, and use:

rigidbody.addforce(Vector3.up * yourjumpforce); (However that is done in js)

The gravity will take care of the trip back down to the ground for you :slight_smile: