Godot Version
v4.5.1.stable.official [f62fdbde1]
Question
I want to make sure that one of the sprites is randomly removed from the array and not shown in the game.
v4.5.1.stable.official [f62fdbde1]
I want to make sure that one of the sprites is randomly removed from the array and not shown in the game.
Sprites are not in arrays. They are in the scene tree. Arrays can only hold references to them.
To remove any node from the scene tree, call queue_free() on its reference. This will remove the node from the scene tree. The reference will still remain in the array but it will become invalid. To remove the reference from an array, you can use Array::remove_at() or Array::erase().
So for a proper cleanup, you’ll need to do both.