After I did a bit of research looking for the answer myself I decided to resort to the forum. In the game that I am working on after the character dies, I would like to delete all instances of one of my game objects. The game objects that are to be deleted are being created dynamically with a factory. My question is, is there a command to simply delete all instances of a certain game object? Is there a way to keep track of all the game objects when they are created? (So I can iterate through and delete them)
There is no built-in go.delete_all() or anything like that. When you create game objects using a factory you get game object ids back. You need to do the book-keeping yourself and delete the game objects when you no longer need them.
The simplest way to do this would probably be a global variable that is set to “true” when your character dies. Then, add a script in your game object saying “if variable is true go.delete()”.
(Someone from defold will now explain to you why global variables are best to be avoided, but I think that whilst you’re learning, they’re not so bad)