# How to keep rigidbody speed constant while jumping?

Hello, I am trying to make my player stay the same speed when it jumps.

Right now it moves at the right speed but when I jump it starts to pick up much speed in the air. Is there a way to keep the speed constant while jumping?

``````using System;
using UnityEngine;
using System.Collections;

public class PlayerScript : MonoBehaviour
{
public float speed = 250f;
public float jspeed = 25f;

public bool jumpAllowed = true;
public bool jump = false;

private Rigidbody rb;
private int _pickupCount;

void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
if (Input.GetKeyDown (KeyCode.Space)) {
jump = true;
}
}

private void FixedUpdate() {

float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

if (jump == true) {
jump = false;
}

}

}
``````

Based on what we can see here, I would assume that your “problem” is related to friction. When the body is grounded, it experiences friction; when it’s not grounded, the same force will produce a greater change in position.

You could theoretically calculate the required change in force by using friction equations, but frankly this sounds messy.

The alternative is: Don’t use friction. Use drag to simulate friction. Drag does not care whether the object is grounded. This approach presents its own set of challenges, but is definitely easier to implement.

The default ForceMode for AddForce is continuous force, that is fine for movement as it’s continuous, but you jump force is applied only once so you either want Impulse, or VelocityChange as the mode. So try

``````rb.AddForce(Vector3.up * jSpeed, ForceMode.Impluse);
``````

Also you should be using `fixedDeltaTime` in FixedUpdate; not `deltaTime`. Make sure you don’t confuse z and y axis.