+1 vote

Hi,

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:

  1. Get player limb position and rotation.
  2. Get player scale and rotation to determine player's local x-axis.
  3. Flip limb position along player's local x-axis.

Could anyone explain how this might be done in GDScript? Thanks

in Engine by (108 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.