Sensing when a player is squished

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

I have recently been making a thwomp-like enemy for my 2D platformer. It’s looking great right now, but I’ve found a concerning edge case:

The player rides the thwomp up to the ceiling, and then gets pushed into the ceiling's collider! They're stuck there for the rest of time.

In general, if a player (a kinematic body) is squished between two walls, they should die. Is there a generalized way to know when something like this is happening and call the appropriate function?

:bust_in_silhouette: Reply From: njamster

As I don’t know your code and/or scene tree, this answer will be rather vague but: Attach a RayCast2D/ Area2D at the bottom and another RayCast2D/Ara2D at the top of of the player. When both collide with a wall and the player is pushed, call die().