How to check if there is an object in a position

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

So I actually have two fairly similar problems.

Problem one: I want to randomly spawn enemies in an x axis but the enemy can spawn inside a wall, is there anyway I could check if there is a wall don’t spawn there?

Problem two: The player can carry a gem but you can drop the gem into a wall, is there anyway to avoid that?

:bust_in_silhouette: Reply From: dethland

You can try to spawn an Area2d first to check the collisions. If there are shapes inside the Area2d you just skip that position.