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

How would I reduce jittering on this RigidBody2D?

$
0
0
So I have this code where it does what I want by moving the player behind the mouse and having a variable speed depending on how far away it is from the cursor, but it jitters a lot. I don't understand how I would fix this annoying problem and smooth it out, since I'm new to C#. There might be another was to do this that I don't know about. I would be very greatful if you could help me understand this, thanks! void FixedUpdate () { //Follow the mouse var pos = Input.mousePosition; pos = Camera.main.ScreenToWorldPoint(pos); var dir = pos - transform.position; rigidbody2D.AddForce(dir * 4); }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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