How to make children's collisons work individually?

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

Hey everybody!

The game is in 2d.
There’s a player and bunch of other objects for the player to grab.
I want to make the player grabbing the objects then move along with them and the player can also rotate as empty handed(rotate in the same grid).
Meanwhile keep their collision shapes.

Here’s the problem:
If I make the objects children of the player, their collisions stop working, because the player can only use his own collisionshape.
If I make the objects children of the player and add the collisions of the objects to player’s collision,the origin of the player will change and mess up its rotating because the game is grid based.
If I use joint to combine them, they will rotate individually, which is not what I need.

I’m totally new to coding and Godot engine, so sorry if this is a basic problem and thanks a lot for anyone who provides any help!

:bust_in_silhouette: Reply From: Blockmaster27

Our project is 3D but the same process might apply:

1.) Instead of adding the dragging objects as children of the player, translate the object WITH the player in a _physics_process(delta) function. Reference the player node using get_node().
2.) Rotate the object by using the player’s rotation in this function.
3.) However, the object will be glitched inside the player if you do not call add_collision_exception_with(DraggingObject) on the player.

If you still want the player to collide with the dragging object, use a dummy marker node’s global transform as the reference point for where you want the object and add that dummy node as a child of the player. Use to_global(transform) on the dummy node to find the global transform (translation + rotation) for the dragging object.

This should place your dragging object in the correct position without all the node inheritance bullshit. I hope this works for you.

The dummy works really well, and I solved another problem with this adorable dummy!
Thank you so much !!!

moredear | 2023-01-26 21:02