RigidBody2D - initial scale, rotation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bruteforce
:warning: Old Version Published before Godot 3 was released.


I’m still working on my 2D ragdoll :).
(Gifs in my previous topic)

There are 2 relevant nodes:
1.) player: this is a kinematic body
2.) corpse: this contains rigid bodies which are connected with pin joints

The corpse node is not in the scene tree until the player dies.

The structure:

player (KinematicBody2D):

- Camera2D (current = on)
- AnimationPlayer
- CollisionShape2D
- Sprite_1 (head image)
- Sprite_2 (neck image)
- Sprite_3 (chest image)

corpse (Node2D):

- Camera2D (current = on)
- RigidBody2D_1 (head)
---- CollisionPolygon2D
---- Sprite (head image)
- RigidBody2D_2 (neck)
---- CollisionPolygon2D
---- Sprite (neck image)
- RigidBody2D_3 (chest)
---- CollisionPolygon2D
---- Sprite (chest image)

- PinJoint2D_1 (head-neck)
- PinJoint2D_2 (neck-chest)

My plan is when the player dies, I replace it’s node with the corpse, like this:


( Sub-question: am I on the right way? :smiley: )

After this I want to initialize the corpse (according to the player’s last values): position, direction (left-right), rotation of the arms/legs… etc.

My problem is that I can not change the corpse node’s direction (left-right).
In the kinematic body I use the set_scale() function for this purpose (with positive/negative X depending on the direction), but I just realised that the rigid bodies are ignoring these values at runtime :(.

How can I do this (without duplication of the corpse node… if possible)?

Thank you!

What if you use a rigid body (or bodies) on kinematic mode and when dies changes to rigid?

eons | 2017-03-06 22:10

Good idea, thank you!
Yes, the scaling works in kinematic mode, but it is reset immediately when I change the mode back to rigid :confused:

bruteforce | 2017-03-07 09:52

if the shapes are symmetric, you can scale/flip the sprites only.

eons | 2017-03-07 15:28

The shapes are asymmetric, and the sprites are not in the center of the main (“corpse”) node :frowning:
Looks like this:
enter image description here

bruteforce | 2017-03-07 16:43

:bust_in_silhouette: Reply From: avencherus

It is by design that rigid bodies don’t scale. There was talk of adding a warning.

The rotation should be fine for some cases.

Here is a more complete explanation:

For scaling you can alter the physics shapes and child sprites directly via script, but that can sometimes turn into a mess with certain node layouts.

OK, rigid bodies are not scalable (design concept), I accept this.
Thank you!

I have to reorganize my nodes, and write this method (horizontal flip) for myself.

I will scale the sprites and the collision polygons directly (not the rigid body), then I calculate their X coordinates… actually it looks easy :slight_smile:

bruteforce | 2017-03-07 09:53