In my game, I have a harmful hazard that periodically drips lava. I also have a hurtbox object that damages the player (The hurtbox is going to be reused many times throughout the game).
I would like for the hurtbox to be created and positioned on top of each drop of lava that exists. Here is what I did so far (Under the Lava Drop group):
It seems to work fine at first. However, a few seconds later, the framerate took a massive dive. It turns out that the lava drops are CONSTANTLY creating hurtboxes on themselves.
I tried to fix this with the use of Trigger Once, but doing so just breaks the code, causing only one hurtbox to spawn on top of the first lava drop.
How can I make it so that each lava drop that exists only spawns ONE hurtbox? Thanks
I mean yeah, but it’s in a separate loop because if I need the lava drop to be created in another way, it will automatically have it’s hurtbox ready. If I have the hurtbox only spawn after it’s created from the hazard, then it won’t have a hurtbox if created any way else.
I also don’t just need help for this just for the lava drop. This solution will be useful for a wide variety of enemy handling.
Then create an object variable for each lava drop when it’s created from the hazard. For example:
The variable hurtbox of lavadrop is 0
Then, in the loop that iterates trough each lavadrop evaluate if the variable hurtbox of the current object is 0 and then proceed to create the hurtbox and set the variable hurtbox to 1. And remember to link the objects, that will be helpful in the further development of your game.