# Should I change velocity or apply force to implement a jump in Unity?

I have started making a basic platformer game just for fun. Its going to be the style of the original Super Mario Bros game, but with 3d assets.

My problem is that I'm using a rigidbody and using code I have always used to make my player object jump. It seems really slow. I am using a capsule object, the standard size (which is 2 units height). I have played about with the mass, ive tried 1 and 40. And other than having to increase the 'jumpForce' value accordingly, it seems to have not changed the jump speed at all.

So I'm hoping there is a way to tweak the flight of the jump whilst still using the Rigidbody component, and if so how please?

If not, I think I'm able to write my own code to make the gravity etc, but this seems stupid since Unity is a well established game framework I expect other people have also needed to change it and I'm sure there is a way I just don't know about.

Hope someone can help me.

Many thanks!

PS (Here is the basic code I have to make the character jump): PPS: It's not super-slow , like being in space. (I've had that problem in LibGDX where my objects scales were all wrong. But this time I have just the standard sized Capsule (1x2 units) and the platform is about 4 units above the ground. He jumps ok, but I'd like to make him jump really-fast like mario can

 public class PlayerController : MonoBehaviour {
Rigidbody rb;
Vector3 faceRight = new Vector3(0, 90, 0);
Vector3 faceLeft = new Vector3(0, -90, 0);
float halfHeight;

float speed = Constants.speed;
float jumpForce = Constants.jumpForce;

private bool IsGrounded()
{
return Physics.Raycast(transform.position, Vector3.down, halfHeight + 0.1f);
}

void Start () {
halfHeight = GetComponent<Collider>().bounds.extents.y;
rb = GetComponent<Rigidbody>();
rb.transform.Rotate(0, 90, 0); // make the capsule face right at start.
}

void Update () {
HandleKeys();
}

void HandleKeys()
{
if (Input.GetKey(KeyCode.A))
{
if (rb.transform.eulerAngles != faceLeft)
rb.transform.eulerAngles = faceLeft;

rb.transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.D))
{
if (rb.transform.eulerAngles != faceRight)
rb.transform.eulerAngles = faceRight;

rb.transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
if (Input.GetKeyDown(KeyCode.Space) && IsGrounded())
{
}
}
}

• Why not set the velocity of the object instead of applying forces? – Bálint Dec 13 '17 at 14:33
• Ah, well thanks for the quick answer firstly! However, I used to do that and ran into physics and gravity problems in older projects, and I was told that changing the velocity etc manually will break the physics simulation – Big T Larrity Dec 13 '17 at 14:35
• There't nothing fundamentally wrong above, though you should beware of mixing Transform and Rigidbody movement as a general rule - this rips control away from the physics engine and can break interpolation / collision response / etc. Your use of an impulse for jumping is just fine, though setting velocity would work too. More on that here. Have you tried just cranking up your jumpForce and gravity parameters to make the vertical movement snappier? – DMGregory Dec 13 '17 at 18:04