Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

AddForce gradually decreasing

$
0
0
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); } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>