Realtime collision for a physics-affected rig??

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AALivingMan

So basically, I am trying to make a stick figure rig that is affected by physics that will be put in a ragdoll-esque state. (it’s kind of like the stick figures from Off The Sticks by Dani, or one that you could put together in Algodoo)

I was able to rig my stick figure together with relative ease, however I’m unsure of how I can have Godot’s 2D physics system handle it. I’m thinking I can parent this rig to a RigidBody2D, but then how can I add collision to it?
If I set up a CollisionPolygon2D I think it will just remain in the shape of the original pose and the shape won’t be determined by the rig itself.
So how could I determine collision via my sprites/bones for a RigidBody2D? Or is there a better way altogether to make a ragdoll rig/rig affected by physics.

EDIT: After toying around with possible fixes a lot and finding nothing I’ll try to be more specific with what I’m trying to achieve: The stick figure is rigged with the bones system so the limbs are connected. That’s how far I’ve gotten. I can’t figure out how to make the body parts stay connected, yet also be affected by physics and move on their own, here’s the hierarchy of everything for the stick figure rig:

Torso, inside that there’s the Head, Right Leg, Left Leg, Right Arm, Left Arm, which are all sprites. The arms and legs are split into an upper and lower section, and inside everything (excluding the torso itself and the upper body parts) there’s a Position2D as an endpoint. I rigged it together using the tutorial from the Godot Docs.

I found that if I made a RigidBody + Collision for every part individually, the physics stuff would work. (although it is messy)
But with this rigging the character together just does not work, so all the body parts move on their own.
Then I tried storing all limbs as a RigidBody on the same layer and connecting them with PinJoint2Ds, still didn’t work at all.

:bust_in_silhouette: Reply From: Andrea

youtube is your best friend :slight_smile:

Unfortunately, nope, didn’t really help. I edited the post giving some more detail.

AALivingMan | 2021-01-17 11:30

Ah, actually, I got it working! The only problem is that for some reason the whole thing breaks if I try scaling the stick figure. Any idea how I can fix that?

AALivingMan | 2021-01-17 12:29

what do you mean with breaks?

Andrea | 2021-01-17 12:44

So, I scale the Node2D, and it looks like it was scaled, but when I run a test it doesn’t scale at all and all the parts get squashed together, I’m guessing this is a problem with RigidBodies since it persists when I delete the Joints. I would send an image but my internet is being terrible right now.

AALivingMan | 2021-01-17 13:09

some time ago i read that it was better to avoid scaling on the collision polygons, and rather actually draw smaller polygons.
dont know if this is still true, but maybe you are being bitten by this old “bug”.

do you need to dynamically scale the rig during gameplay?

Andrea | 2021-01-17 13:25

Well, I do use CollisionPolygons. But I can just change them to CollisionShapes if that’ll fix it, since I’m only using circles and capsules. (I used Polygons instead since the capsule sprite I had and Godot’s capsule weren’t the same and I wanted absolute precision for collision)

What do you mean by “dynamically scale?” I don’t plan on scaling the rig during gameplay anytime other than when it spawns so that it’s small enough to fit the screen.

AALivingMan | 2021-01-17 13:31

that was exactly what i meant: in that case it would be wiser to create all the objects (mesh, collision polygons, pin distance, etc) to have their final dimension already in the editor, and to keep the scale value =1

Andrea | 2021-01-17 14:19