How do I detect collision between area2d and staticbody2d

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

Hello Everyone,

I have a chest that I want to open went the player casts a spell(bullet).

The chest is a staticbody2d node and the bullet is an area2d node.

The bullet disappears easily when colliding with the chest. Now I want that the chest detects that collision and opens up (play the open animation).

I can’t seem to find out how that should happen since I can’t see any signals in the static body that can help me.

I’d appreciate any directions.

Thank you.

:bust_in_silhouette: Reply From: wyattb

Did you add a CollisionShape2D and set its shape in the inspector?

Also check this

I did.

As far as I understand from the thread you mentioned, it’s not an ideal way to do it. ( Or have I missed the point)

I’m having a super weird problem. If the make my chest into an area2d node the player stops colliding with it. The bullet works but so do all the objects that have a collision box.

If the keep it an area staticbody2d node I don’t know how to have it interact with the bullet.

How can I specify just this

If the bullet collides with object → object shakes

whoisda | 2021-06-02 12:41

:bust_in_silhouette: Reply From: Zoford

You need to connect the “body_entered” signal on the Area2D.

Emitted when a PhysicsBody2D or TileMap enters this Area2D. Requires monitoring to be set to true. TileMaps are detected if the TileSet has Collision Shape2Ds.

PhysicsBody2D is inherited by Area2D