Could you please help a scripting noob make a box jump?

Hello, first off thanks for any help you can give.
I’ve Very new to scripting/programming/unity in general.
Infact I only picked up Unity(free edition) two days ago.
I’ve watched a bunch of tutorials and have make a little project to try to learn with.

I’m trying to script a rigidbody box collider to jump when I press Space, the code won’t run however, I get and error

Here’s My Code, I’ve commented heavily on it, since I’m probably making a number of mistakes.

using UnityEngine;
using System.Collections;

public class Jump : MonoBehaviour {

	public float jumpforce = 10f;	
	/* I have a Public Variable here that will later be multiplied by 
	the vector to make hump height editable form the component panel*/
	private bool isgrounded 
		// This Bool is for determining if the box is on the 
              //ground, its required for jumping
	void FixedUpdate () { 
		/* I've Changed update to fixed update because I 
             *heard Fixedupdate is better for Physics
		 * This is also the only void in the code, which is what the
             * console says is causing the error.
		 * I put void because I don't see why I'd want the 
             *console/engine to give me anything,
		 *I just want it to run the IF line and then the transform line
		 * I don't want it to give me anything. this segment shouldn't 
		 * produce a integer or boolean or anything, right?   */
		if(Input.GetKey(KeyCode.Space) && isgrounded == true) 
// my understanding is that ^this line will check for a [Space] key press and 
//whether or not the "isgrounded" bool is true. If the key is pressed and the 
//Bool is true it should advance to the next line right?
		 * I have no idea what I'm doing with ^this line, 
		 * I'm trying to get it to add upward momentum(causing a upward Jumping     
		 * motion) to  the rigid body the script is applied to but I haven't 
		 * been able to run the script. 
		 * -- due to an "unexpected symbol "void"" error
		 Is there a better way of doing this? like 

bool OncollisionStay()
		isgrounded = true;
bool OncollisionExit()
		isgrounded = false;

	/* Here I've setup a variable that I want to indicate whether or not the box is 
	on the "ground".My box is a rigidbody with gravity  
	so it should fall onto a cube. I've set it as a Boolean because
	I figure the box is either touching the ground or it isn't.
	I also thought about setting it to false after the jump line, 
	but then it wouldn't apply if the box fell from a ledge, because I would have   
    never pressed space.

Thanks again for any help you can give.

Thanks to both Mr Slayer and robertbu, robertbu in particular as his code (Kindof)worked, and you helped me to understand what I’m doing.

Unfortunately now the Cube will jump, but will also jump in mid air.
(Mashing spacebar will shoot it into orbit)
It seens that for some reason the OnCollisionStay/Exit segment isn’t working, and I have no idea why.

I tried removing the box collider(I figured there might be a collider included in ridigbody,that coulb be interfereing, there wasnt).

I also tried changing the collision detection settings under rigidbode: Discrete, Continuous, and Continuous dynamic all suffer the same problem,

The script isnt registering that it isnt colliding with anything I even put in Debug calls in the collision segments

void OncollisionStay()
		isgrounded = true;
		Debug.Log ("CollisionStay");
	void OncollisionExit()
		isgrounded = false;
		Debug.Log ("CollisionExit");

However jumping up and down left me with an empty console.

I’m stumped, I know you just helped me but do you have any Ideas?

Not sure if this will be posted twice or not but the one thing I see right off the bat is that
private bool isgrounded
does not have a ; at the end of it could you please post your error?

  • Line 9: missing a ‘;’ at the end.
  • Lines 40 and 44: OnCollisionStay() and OnCollisionExit() are ‘void’ not ‘bool’.
  • Line 28: you are trying to translate the object. Since this game object has a Rigidbody, use AddForce() to get it to jump.
  • Line 13: Change to Update(). Typically you want to do physics things in FixedUpdate(), but a one-time application of force in Update() is fine. Plus it is not good to be checking Input.GetKeyDown() inside of FixedUpdate(). You can miss keystrokes that way.
  • Line 24: Use Input.GetKeyDown() instead of Input.GetKey(). GetKeyDown() returns true only for the frame the key goes down. GetKey returns true while the key is held down. You would not want to allow the use to hold the key down and have the object jump a second time. In addition, since Update() and FixedUpdate() run at different frame rates, it might be possible to get two or more AddForce() calls before the object moved enough for isgrounded to be false.

Putting all those changes together (and removing the comments to compact the code):

using UnityEngine;
using System.Collections;

public class Bug25a : MonoBehaviour {
	public float jumpforce = 250.0f;  
	private bool isgrounded = true; 
	void Update () { 

		if(Input.GetKeyDown(KeyCode.Space) && isgrounded) {
	void OncollisionStay() {
		isgrounded = true;
	void OnCollisionExit() {
		isgrounded = false;