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().velocity = Vector2.zero;
rb.GetComponent().AddForce(transform.up *
jumpForce);
}
}
↧