Page 1 of 1

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

Posted: Wed Feb 05, 2020 10:29 pm
by iimurpyh
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!

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

Posted: Thu Feb 06, 2020 3:04 am
by pgimeno
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.

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

Posted: Sat Feb 08, 2020 9:13 pm
by iimurpyh
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.

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

Posted: Sun Feb 09, 2020 7:45 pm
by pgimeno
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.