Hello , How i can make 2d Area Collide with Two Different Rigid Body ?

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

hello there, i’m new to GODOT and i really like it I used to programe mini games with pygame

my character is 2d Area and There is 2 different objects (Rigid Bodies 2D) falling from the top of the screen

the character have to avoid an object and have to collect the other one in order to to get score
.
The area 2D collides only with one rigid body 2D
.
is there a way to make Area 2D Accept more than one collision with different results ?
.
( Collision To lose the game , Collision to get score)
.
i succeed when i made the other object a 2D area too… but i want the objects to be rigid bodies only

Thank you

:bust_in_silhouette: Reply From: Atomic Potato

Welcome to the Godot community!

I would recommend that you add each rigid body to it’s own group. For example you could add one of them to a group you call points. Then connect the body_entered(body: Node) signal from your Area2D to your level script. Then you can write something like this inside your script:

func _on_Area2D_body_entered(body):
    if body.is_in_group("points"):
        #some function to gain points
    #here you can add the same for the other rigid body

I hope it helps :slight_smile:

Thank You So much :slight_smile: I will try it

Zylo_X | 2020-04-13 14:11