how to fix velocity for jump and movement or fall in 2d pltform game with gravity

Hello everybody ,

Please help me and thank you ,

I use fixed update a movement function with rigidBody2D.Velocity to move my character in 2d platform game (with rigidbody2D.velocity = new vector 2 (movement on x, rigidBody2D.velocity.y) and another jump function Except to jump in addition to this function,

The problem is that gravity is either very slow with a simple jump or very fast with a big fall with sometimes the range of the jump that varies,

Please what is the simplest and fastest and most realistic and adequate formula to determine the rigidBody.velocity in this case and what is the most suitable 2d mode force in this case,

thank you infinitely and good day.

Cordially.

Is it possible to paste your exact code? becaue I think you are just making a small mistake.

Here is the code below (not complete it also misses may be block of code)`

void FixedUpdate ()   
	{           
	
if ((!Input.GetKey (KeyCode.RightArrow) && !Input.GetKey (KeyCode.LeftArrow)) && Input.GetAxis ("L_XAxis_1") == 0 && Input.GetAxis ("DPad_XAxis_1") == 0) {
							h = 0;
							rigidBody.velocity = (new Vector2 (h, rigidBody.velocity.y));
							anim.SetFloat ("speed", 0f);
							sons.audioSource.Stop ();
						}
						if (!Input.GetKey (modes.boutonX) && !Input.GetKey (KeyCode.Joystick1Button1)) {
							sons.audioSource.clip = sons.walk;
							if (Input.GetKey (KeyCode.RightArrow) || Input.GetAxis ("L_XAxis_1") > 0 || Input.GetAxis ("DPad_XAxis_1") > 0) {
								h = 1;
								sons.audioSource.Play (44100);
								anim.SetFloat ("speed", 1f);
							}
							if (Input.GetKey (KeyCode.LeftArrow) || Input.GetAxis ("L_XAxis_1") < 0 || Input.GetAxis ("DPad_XAxis_1") < 0) {
								h = -1;
								sons.audioSource.Play (44100);
								anim.SetFloat ("speed", 1f);
							}
							rigidBody.velocity = (new Vector2 (h * moveForce, rigidBody.velocity.y));  
							anim.SetBool ("X", false);
						}
						if (Input.GetKey (modes.boutonX) || Input.GetKey (KeyCode.Joystick1Button1)) {
							sons.audioSource.clip = sons.run;
							if (Input.GetKey (KeyCode.RightArrow) || Input.GetAxis ("L_XAxis_1") > 0 || Input.GetAxis ("DPad_XAxis_1") > 0) {
								h = 1;
								sons.audioSource.Play (44100);
								anim.SetFloat ("speed", 1f);
							}
							if (Input.GetKey (KeyCode.LeftArrow) || Input.GetAxis ("L_XAxis_1") < 0 || Input.GetAxis ("DPad_XAxis_1") < 0) {
								h = -1;
								sons.audioSource.Play (44100);      
								anim.SetFloat ("speed", 1f);     
							}
							rigidBody.velocity = (new Vector2 (h * maxSpeed, rigidBody.velocity.y));         
							anim.SetBool ("X", true);
						}
					}
}
					Jump ();
}

//function flip too in Update ()

	void Jump ()
	{           
		if ((Input.GetKeyDown (modes.buttonSpace) || (Input.GetAxisRaw ("Jump") > 0)) && jump) {
			if (nombrejump >= 0) {      
				jumpNumber--;
				jumpOk = true;                 

				rigidBody.AddForce (new Vector3 (0, -h1 * jumpForce * Time.deltaTime, 0), ForceMode2D.Impulse);        
				jump = false;                   
			}
		if (Input.GetAxisRaw ("Jump") == 0 && !Input.GetKeyDown (modes.buttonSpace) && !jump) {        
			jump = true;     
			jumpOK = true;
		}
	}

void FixedUpdate ()
{
if ((!Input.GetKey (KeyCode.RightArrow) && !Input.GetKey (KeyCode.LeftArrow)) && Input.GetAxis (“L_XAxis_1”) == 0 && Input.GetAxis (“DPad_XAxis_1”) == 0)
{
h = 0;
rigidBody.velocity = (new Vector2 (h, rigidBody.velocity.y));
anim.SetFloat (“speed”, 0f);
sons.audioSource.Stop ();
}
if (!Input.GetKey (modes.boutonX) && !Input.GetKey (KeyCode.Joystick1Button1))
{
sons.audioSource.clip = sons.walk;
if (Input.GetKey (KeyCode.RightArrow) || Input.GetAxis (“L_XAxis_1”) > 0 || Input.GetAxis (“DPad_XAxis_1”) > 0)
{
h = 1;
sons.audioSource.Play (44100);
anim.SetFloat (“speed”, 1f);
}
if (Input.GetKey (KeyCode.LeftArrow) || Input.GetAxis (“L_XAxis_1”) < 0 || Input.GetAxis (“DPad_XAxis_1”) < 0)
{
h = -1;
sons.audioSource.Play (44100);
anim.SetFloat (“speed”, 1f);
}
rigidBody.velocity = (new Vector2 (h * moveForce, rigidBody.velocity.y));
anim.SetBool (“X”, false);
}
if (Input.GetKey (modes.boutonX) || Input.GetKey (KeyCode.Joystick1Button1))
{
sons.audioSource.clip = sons.run;
if (Input.GetKey (KeyCode.RightArrow) || Input.GetAxis (“L_XAxis_1”) > 0 || Input.GetAxis (“DPad_XAxis_1”) > 0)
{
h = 1;
sons.audioSource.Play (44100);
anim.SetFloat (“speed”, 1f);
}
if (Input.GetKey (KeyCode.LeftArrow) || Input.GetAxis (“L_XAxis_1”) < 0 || Input.GetAxis (“DPad_XAxis_1”) < 0)
{
h = -1;
sons.audioSource.Play (44100);
anim.SetFloat (“speed”, 1f);
}
rigidBody.velocity = (new Vector2 (h * maxSpeed, rigidBody.velocity.y));
anim.SetBool (“X”, true);
}
}
Jump ();
}

//function flip and Jump too in Update ()

void Jump ()
{           
                   if ((Input.GetKeyDown (modes.buttonSpace) || 
                  (Input.GetAxisRaw ("Jump") > 0)) && jump) 
                    {
		            if (jumpNumber >= 0) 
                            {      
			    jumpNumber--;
			    jumpOk = true;
                          }                 
                         if(jumpOk)
                        {
			    rigidBody.AddForce (new Vector3 (0, -h1 * jumpForce * Time.deltaTime, 0), ForceMode2D.Impulse);        
			     jump = false;                   
			}
		      if (Input.GetAxisRaw ("Jump") == 0 && !Input.GetKeyDown (modes.buttonSpace ) && !jump) 
                      {        
			jump = true;     
			jumpOK = true;
		      }
}