0 votes

So basically I'm making a tower defense game and when an enemy enters an Aera2D I add it to an array but when he exists I want him to be removed from an array. As far as I know, since this is a smaller game performance shouldn't be a problem so I think it should be fine. So basically how do I find and remove a specific item from an array based on its name?

Godot version 3.2.3
in Engine by (26 points)

1 Answer

+1 vote
Best answer

You could do this:

for item in array:
     if item.name == "name":

Just replace array with whatever your array is called, and "name" with whatever item you want to remove's name.

by (450 points)
selected by
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 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 webmaster@godotengine.org with your username.