- Home /
Making SpringJoint2D's spring force instantaneous
Here's the kind of snappy interaction that I want (from Allan Bishop's Box2D tutorial):
And here's what I currently have. I've implemented picking and dragging by rewriting DragRigidbody.js (from Standard Assets/Scripts
) with the appropriate 2D API calls. Essentially, an empty GameObject is created and a SpringJoint2D is attached to that empty GameObject. While the left mouse button is held down, the empty GameObject's position is set to the current mouse position. This drags the attached object along.
Within my script, the frequency is set to 2.5 and the damping ratio is set to 1.0. I can try increasing the frequency for a stiffer spring, but it's not the instant snap behavior I want.
Why is my version far less snappy?
There was the same problem. To make the damping ratio greater than 1, for example = 4, just copy the SpringJoint2D four times. Changing linear drag and angular drag will affect the movement of the object, this is the wrong answer. Thank!
Answer by Mango-Man · Dec 19, 2013 at 04:38 PM
This can be remedied by tweaking the Rigidbody2D's linear drag and angular drag. So ultimately there are four parameters to get just right: the damping ratio and frequency on the SpringJoint2D, and the linear drag and angular drag on the Rigidbody2D.
There was the same problem. To make the damping ratio greater than 1, for example = 4, just copy the SpringJoint2D four times. Changing linear drag and angular drag will affect the movement of the object, this is the wrong answer. Thank!