Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | bruteforce | |
Old Version | Published before Godot 3 was released. |
Hi,
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)
(etc.)
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)
(etc.)
- PinJoint2D_1 (head-neck)
- PinJoint2D_2 (neck-chest)
(etc.)
My plan is when the player dies, I replace it’s node with the corpse, like this:
remove_child(player);
add_child(corpse);
( Sub-question: am I on the right way? )
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
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
Looks like this:
bruteforce | 2017-03-07 16:43