How to avoid "springy-ness" with WeldJoints? [SOLVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
iimurpyh
Prole
Posts: 6
Joined: Tue Feb 04, 2020 1:02 am

How to avoid "springy-ness" with WeldJoints? [SOLVED]

Post by iimurpyh » Wed Feb 05, 2020 10:29 pm

When making weldjoints between objects, they act very springy and not at all 'as one body,' like you'd expect welded joints to be.
Here's a GIF to show what I mean:
Image

I know this can be avoided with some combination of DampingRatio and Frequency settings, but I can't seem to find a good spot between "way too springy" and "uncontrollable spinning mess."

(Sorry the image is so big, can't seem to resize it with BBCode :? )

EDIT: Solved using pgimeno's solution, thanks for the help!
Last edited by iimurpyh on Tue Feb 11, 2020 10:15 pm, edited 1 time in total.

User avatar
pgimeno
Party member
Posts: 2181
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to avoid "springy-ness" with WeldJoints?

Post by pgimeno » Thu Feb 06, 2020 3:04 am

To make them act as one body, make them actually one body (by attaching the fixture to a single body) or, if you won't move them at all, make them static.

User avatar
iimurpyh
Prole
Posts: 6
Joined: Tue Feb 04, 2020 1:02 am

Re: How to avoid "springy-ness" with WeldJoints?

Post by iimurpyh » Sat Feb 08, 2020 9:13 pm

pgimeno wrote:
Thu Feb 06, 2020 3:04 am
To make them act as one body, make them actually one body (by attaching the fixture to a single body) or, if you won't move them at all, make them static.
It seems like setting one object's body to the other object's causes the first to teleport to the second's center. How should I avoid this?

Edit: Seems like it's actually an issue with the way I'm drawing the objects, I've been using the position/rotation of each object's body, and since there are two fixtures under one body it draws both as being in the same position. There's no way to get the position or rotation of an individual fixture, though...

Edit 2: You can do some math depending on the shape of the fixture to get it's position/rotation, so that's what I ended up doing to fix the draw issue.
Last edited by iimurpyh on Tue Feb 11, 2020 10:16 pm, edited 1 time in total.

User avatar
pgimeno
Party member
Posts: 2181
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to avoid "springy-ness" with WeldJoints?

Post by pgimeno » Sun Feb 09, 2020 7:45 pm

iimurpyh wrote:
Sat Feb 08, 2020 9:13 pm
It seems like setting one object's body to the other object's causes the first to teleport to the second's center. How should I avoid this?
That depends on the shape. For polygon shapes, you need to offset every vertex. Use body:getLocalPoint on the original body's position to determine the offset to apply to each vertex.

I can't give any better advice without seeing some code, sorry.

Edit: It seems it's not possible to edit the shape's points, therefore both fixture and shape need to be recreated.

Edit2: Proof of concept attached (press space to fuse the objects). debugWorldDraw is by forum member Azhukar, modified by me to run on 11.x.
Attachments
fuseObjects.love
(1.83 KiB) Downloaded 55 times

Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests