Better jumping with Character Controller 2D

Hello,
I am making a 2D platformer and I want to Improve my jumping.
I want my character to jump even if he doesn’t touches the ground right now, but in the following 0,2 sec.
I use brackeys Character controller script(link text)

So I replaced this code(Line 137):`

if (m_Grounded && jump)
       {
		// Add a vertical force to the player.
		m_Grounded = false;
		m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce));
		
	   }

By that one:`

        JumpTimer -= Time.deltaTime;
		if (jump)
			
		{
			
			JumpTimer = JumpTime;
		}
		if ((JumpTimer > 0) && m_Grounded)
		{
			m_Grounded = false;
			m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce));
		}`

and I add two variables (private float JumpTimer; public float JumpTime=0,2;)
This code is called in the move function, wich will be called in the FixedUpdate function.
But when I play the game with the “improved jump code”, I jump very very high, which isn’t a problem because I can just decrease the Jump height, but when I die and the scene gets reloaded I jump even higher and thats my problem.
Do I have to reset sth. when I reload the scene?


Update: I figured out that he is jumping so high because " m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce));" gets called twice but I don’t know why it only happens when I reload the scene.
Any Ideas?


try this

if (m_Grounded && jump)
    		{
    			// Add a vertical force to the player.
    
                // Initialize velocity
                m_Rigidbody2D.velocity = Vector3.zero;

    			m_Grounded = false;
    			m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce));
    		}