Jumping with ball...

Hello i have a script to move the player its a ball here it is :

Vector3 movement = (Input.GetAxis("Horizontal") * -Vector3.left * movementSpeed) + (Input.GetAxis("Vertical") * Vector3.forward *movementSpeed);
        rigidbody.AddForce(movement, ForceMode.Force);

and to make it jump i use this script :

  if (Input.GetKeyUp("space"))
        {
            rigidbody.AddRelativeForce(transform.up * jumpForce, ForceMode.Impulse);
        }

whats wrong with it because when i press space when its not moving it jump’s normaly but when i move and press space it doesnt jump just launches the player at the direction im moving any ideas?

up…

nvm problem solved :slight_smile: if someone wants to know just pm me :slight_smile:

My guess, is that your ball is rolling when you move it.

Try:

if (Input.GetKeyUp("space"))
        {
            rigidbody.AddRelativeForce(transform.InverseTransformDirection (transform.up * jumpForce, ForceMode.Impulse));
        }

EDIT: You should go ahead and post how you fixed it for others. On another note, 400 posts!