I have this class:
As you can see there is a Group called bullets inside this Container.
I want to destroy any enemy that goes beyond a certain point in the map so i use this update function:
I want to know what happens to the Group when the Container is destroyed. Since the bullets it shoots stay on canvas even after the enemy is destroyed
My second question is about events. In the same class I have this two functions:
I want this enemy to shoot a bullet every 500ms so in the Enemy class I call for an event. The problem here is that even after an enemy is destroyed, there still is an event for it to shoot a bullet, so when the time comes an exception is thrown. I solved this an if statement that checks for a scene (if an enemy is destroyed then it’s scene will be undefined) but this feels hacky. I tried to remove every event from the scene but this stops everyone from shooting. Is there a better way to solve this? Can I give the event to GameObject Instead of The scene? How do I remove this specific event?