coding the jump

how do I code a jump to the spacebar

If you want to write something like this yourself instead of using the FPS controller prefab provided in the standard assets, you could use the example provided here if you're using a character controller:


If your player object is using a rigidbody component, you would use something like this:

var jumpSpeed = 5.0;

if (Input.GetKeyDown(KeyCode.Space))

    rigidbody.AddForce(Vector3.up * jumpSpeed, ForceMode.Impulse);

(of course you would have to implement your own method of detecting whether your player is on the ground in this case).

Look in the FPSWalker script in Standard Assets.