How to make my game detect when the character is stuck in tiles?

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

When you press certain buttons in my game, the tilemap is flipped horizontally or vertically (however the player, enemies and objects remain the same).
It’s better to use area2d or get the total cells that my collision shape use (only the middle one is counted when i want all)? The priorities are to move the player up or down (depending on which one is the fastest way to get out the tile/s (if in the middle, then up)) and right or left (same criterion) if there’s no space in the previous directions.