problem with the jump code..

iam learning eteeski’s fps1.5 jumping the right way game tutorial in which, my player has to jump when i press space bar.the code for jumping is as follows,

**

    var walkacceleration : float;
    var cameraobject : GameObject;
    var maxwalkspeed : float = 20;
    @HideInInspector
    var horizontalmovement : Vector2;
    var jumpvelocity : float = 20;
    @HideInInspector
    var grounded : boolean = false;
    var maxslope : float = 60;
    function Start () {
    }
    function Update () {
    horizontalmovement = Vector2(rigidbody.velocity.x, rigidbody.velocity.z);
    if(horizontalmovement.magnitude > maxwalkspeed )
    {
    horizontalmovement = horizontalmovement.normalized;
    horizontalmovement *= maxwalkspeed;
    }
    rigidbody.velocity.x = horizontalmovement.x;
    rigidbody.velocity.z = horizontalmovement.y;
    transform.rotation = Quaternion.Euler(0 ,cameraobject.GetComponent(lookupscript).currentyrotation, 0);
    rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkacceleration, 0 , Input.GetAxis("Vertical") * walkacceleration);

    **if(Input.GetButtonDown("Jump"))
    rigidbody.AddForce(0,jumpvelocity,0);**
    }

**

the problem is my player is not jumping when i press my spacebar.
can any one help me.

Force is applied over time, but your jump code only applies the force when the spaceBar is pressed. To use force like this (triggered once but affect the rigidbody properly), you need to use ForceMode.Impulse

eg :

if(Input.GetButtonDown("Jump")) {
    rigidbody.AddForce( Vector3(0,jumpvelocity,0), ForceMode.Impulse );
}