Nested colision detection

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

I’m trying to detect collision between different objects that are not under the same parent but failed to achieve what I want.

note scene
here is a scene for Note. this scene is simply and image with an Area2D and a collision shape to detect collision.

Here is the main scene
this is the main scene with a lot of control nodes. But here two are particularly important.
The Note node which is of type RigidBody2D is supposed to slide down with a constant speed toward the bottom. This node doesn’t need detection collision yet. it will contain multiple note scenes and make all this “note” slide down with the body.
there is also and Area2D with a collisionShape2D. this one is fixed and doesn’t move.

My problem is that Notes are sliding down because they are parents to the RigidBody? but once they reach the bottom and should detect collision with the static Area2D nothing happened.

what should I do to make it work ? is nested collision impossible with godot? is detection collision incompatible with Control node?

Firstly your rigidbody has no CollisionShape child node. Secondly “is detection collision incompatible with Control node?” Yes but the rigidbody must be the parent. Thirdly what are the scripts doing? Are they just signals or are they also controlling movement?

Magso | 2020-10-02 10:51

Thank you for your response.

rigidbody has no CollisionShape child node.

Yes, I made it so because I do not need this rigid-body to detect collisions. I just use to make all its children slide down at a constant velocity. It’s the children of this rigid
body I want to detect.

Yes but the rigidbody must be the parent

I changed the control and made it only with Area2D instead of using the control node. now it seems to work. But I have some trouble when instancing the node. I guess I have to rewrite the behavior of the “note”

what are the scripts doing?

Right now nothing it’s just signaling. I want to detect when a “note” hit the bottom of the screen via the built-in collision detection of godot. I use Area_entered() since I work with Area2D.

alternatif | 2020-10-02 11:13

The Control node script will have to extend Area2D and cannot use Control methods or properties unless you reference a control node before hand.
Also regarding the RigidBody, the children will need a CollisionShape as their parent however when detected the entire RigidBody is detected not just the CollisionShape children. They will all need RigidBodies to each be detected.

Magso | 2020-10-02 13:09

Thank you very much,

Now it is working. I needed to make the children of the Rigid body Area2D.
Now collisions are being detected as expected.

alternatif | 2020-10-03 08:14