0 votes

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?

Godot version 3.5
in Engine by (18 points)

It will be false if there is no node

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

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.