Colision with two kinematic body

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

I have a kinematic body, that’s moving with move_and_collide and it’s stopping when meet a second kinematic body and it’s ok but I don’t know how to recognize what’s the cinematic body in collision

:bust_in_silhouette: Reply From: GlitchedCode

Add an area2D onto your body and give it a collisionshape that is a little larger than the one you have for colliding. You can now connect the signal from your area2D of body_entered. From here it is up to you how you want to get your bodies, for example:

You could use:


This will return an Array of all physicsbodies that are within the area2d boundaries. If you go this route, be aware that this will also include the physics body it is attached too as the first element.

Alternatively, since the signal passes in the body that entered the area, you could get information from that body to find out which it is. As an example:

body.is_in_group("my group name")