I'm trying implement a ragdoll effect in my 2D game. This is done by instancing a PackedScene ragdoll (made of
Rigidbody2D) and adjusting each limbs' position and rotation according to those of the original player. This works when the player's
scale.x = 1, but is no good when flipped horizontally so
scale.x = -1. The ragdoll appears to explode.
With a bit of research I think this can be sorted by using some of the
Transform2D methods, but I'm not sure exactly which ones. I think the process should be:
- Get player limb position and rotation.
- Get player scale and rotation to determine player's local x-axis.
- Flip limb position along player's local x-axis.
Could anyone explain how this might be done in GDScript? Thanks