Does collision between two Area2D work differently than collision with Rigidbody2D
Yes.
the collision between Player and Trap (Area2D vs Area2D) does nothing. Is it expected?
Yes.
We have three main PhysicsBody2D types:
StaticBody2D: Intended to not move. If you move it by code it causes no collision response (if you want to move it, it is easier to use KinematicBody2D instead). And it does not provide collision response for things colliding into it (handle those collision on things that can collide into it). KinematicBody2D: Intended for you to move it from code. Movement can cause collisions. You are supposed to handle collision response from code. RigidBody2D: Intended to be moved by physics. You can apply forces to change the way it moves, but ultimately physics moves it (to move it directly make sure to set the mode as needed or you will be fighting the physics system, an that is a potential source of glitches). Godot handle collision response by default.
The type Area2D is not in that list because it is not a physics body. Instead both Area2D and PhysicsBody2D are both CollisionObject2D.
A consequence is that the "body_entered" signal in Area2D, will detect StaticBody2D, KinematicBody2D, RigidBody2D but not other Area2D.
It is possible to detect overlapping between Area2D by using get_overlapping_areas.
However, the intended way to do things is to:
- Make the player avatar a
KinematicBody2D. The icon of KinematicBody2D should be a clue. - Put the collision logic on the
Area2D.
That is, the trap (Area2D) would detect the player avatar (KinematicBody2D) and act on it.
That leaves the question of how to handle the rock (RigidBody2D) collision with the player avatar (KinematicBody2D). Well, RigidBody2D also has a "body_entered" signal that you can use for that.
I also mentioned that you can handle collision in your KinematicBody2D, that would be with move_and_collide or get_slide_collision. However, note those are meant to handle collisions are result of the motion of the KinematicBody2D. Thus, when a RigidBody2D (which is handled by physics) hits the KinematicBody2D, you probably want to handle that on the RigidBody2D.
Another advantage of placing the collision response logic on the objects that the player avatar can collide with, is that the player avatar code is not aware of them. As a consequence it is easier to extend the logic of the game by adding more things that response to collision with the player avatar.
More complex collision logic can be archived by having Area2D as child of a KinematicBody2D or using RayCast2D.
Note: "body_entered" will also handle collision with tile with collision shapes from a tilemap even though a tilemap is not a physic body.