# Jump Issue(Unity3D)

This is my first character control script.
Where a cube is my player and the objective the i want to achieve with my script are
1.the cube moves in horizontal axis till the button is pressed once release the cube should stop(done)

2.the cube should has max vertical speed when the button is press the cube should move in vertical direction and try to reach the max-speed but when the button is released the cube should move at that speed continuous unless an opposite force is applied(done)

3.the cube should be able to jump (failed)

I want to make the cube jump but it just sticks to the ground. When gravity is turn on it jump but does not move forward and when gravity is turn off it moves forward but when pressed Jump it does not come down continuously move up. if anyone have played classic skyroads game am try to make that but a simple one without using raycast etc.

void FixedUpdate ()
{
shipvelo = rigidbody.velocity;
shipmagno = rigidbody.velocity.magnitude;

Vector3 vel = rigidbody.velocity;
vel.x = Input.GetAxisRaw("Horizontal") * MaxHorSpeed;

if (Input.GetKeyDown(KeyCode.Space) && IsGrounded()){
vel.y = jumpSpeed;
print("I am on");
}

rigidbody.velocity = vel;

rigidbody.AddForce (Vector3.forward * Input.GetAxis("Vertical") * forSpeedMul);
rigidbody.velocity = new Vector3(Mathf.Clamp(rigidbody.velocity.x, -horizantalClamp, horizantalClamp),0,Mathf.Clamp(rigidbody.velocity.z, -VerticalClamp, VerticalClamp));
}

– House
Dec 7, 2014 at 15:46
• You've edited the code and question to change what's being asked, I've reverted that. I suggest you accept the below answer as correct (because it apparently helped you remove that bit of code from your update), then ask a new question with the details of the problem you have now. Please ensure your new question contains all the information you want before it's answered.
– House
Dec 11, 2014 at 7:48
• My dear friend the answer didn't helped me and it did not worked all so I edited and removed to part of the code that was not necessary because the code that i want is not present consent. it is full of bug Dec 11, 2014 at 13:31

if (Input.GetKeyDown(KeyCode.Space) && IsGrounded())