Is it possible to detect sprites at a specific location?

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

In my code I’m instancing an animated sprite at locations dictated by the player. I’m trying to make it so that you can’t instance a sprite if there already is a sprite there.

Is there a way to detect if there is a sprite at a location using an if statement? If not how would you suggest going fixing this problem?

It will be false if there is no node
has_node(“nodename”)

if has_node("nodename"):
     print("bla bla")

ramazan | 2022-09-18 07:55

Are your sprites attached to Areas or Bodies? If so, I would create an Area2D in the area, and use it to check for other overlapping areas/bodys. If it’s clear, you can add your sprite.

SteveSmith | 2022-09-20 19:34