- Home /
 
 
               Question by 
               GuessWhoCro · Nov 18, 2020 at 05:35 PM · 
                rigidbody2daddforcerigidbody.addforce  
              
 
              AddForce gradually decreasing
Hi, I'm making a game where the ball jumps on bounceable objects and I accomplish that by adding force on the 2d rigidbody. As it is an infinite runner game, after some time i noticed that ball jumps lower and lower after some time. Force that I'm adding isn't changing, as well as its mass so I can't find the problem.
 public float jumpForce = 130.0f;
 public GameObject rb;
 
  private void OnCollisionEnter2D(Collision2D collision)
     {
         if (collision.collider.tag == "BO")
         {
             hits = 0;
             rb.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
             rb.GetComponent<Rigidbody2D>().AddForce(transform.up * 
             jumpForce);
         }
 }
 
              
               Comment
              
 
               
              is the jump force being modified outside of this script? @GuessWhoCro
I think the problrm you have it's in the gravitatory force of the rigidbody.
Your answer