Jump Code Not Working (2D C#)

So I’m making a 2D platform game in which I need my character to jump, but I am having some issues. (I am scripting with C#). I am very new to Unity, so keep that in mind. I haven’t seen anyone else with my problem, and I’ve been searching for a while. (Or maybe I misinterpreted how this function is supposed to work and this is intended) This is the code for jumping in my PlayerControl script:

if (Input.GetKeyDown (KeyCode.UpArrow)) {
			if (!inAir) {
				rb.AddForce(Vector2.up * jumpHeight);
			}
		}

To me it seems pretty simple and self-explanatory. rb is my RigidBody2D, and jumpHeight is a float. inAir is a boolean I made to check if he is already in the air or not, and this check works perfectly by my testing. The problem? Well, the jump is really tiny and fast, it just looks like my character glitches up and then back down, and the weird part is that no matter what I set the jumpHeight to, it is always the same. If I set it to 50000, it is still a tiny little glitch jump. I would consider myself a intermediately advanced programmer, but I am completely new to Unity, so if there is a Unity related mistake that could be the problem, but you are not saying because it just seems so stupid and obvious, please say it anyway, it might be the problem.

EDIT: Everyone is asking me if this is in the Update() function and it is. In fact, it is in the FixedUpdate() function.

try adding a type of ForceMode:

rb.AddForce(Vector2.up * jumpHeight, ForceMode.Acceleration);

you can play with the type of ForceMode here

Hi @RothX,

Make sure your code is inside Update() method and Rigidbody2D component is attached to the player object.

Good practice is to put your physics based code inside FixedUpdate() method.

void FixedUpdate () {

        if(Input.GetKeyDown(KeyCode.Space)) {
                rb.velocity = Vector3.Up * jumpHeight;
        }
        
}

I hope, this will help.

Cheers.