I have a top down survival game where enemies spawn every 3 seconds and i want that enemies that are outside the viewport are getting destroyed after an certain time so the layout isnt completly filled with them after like 3 minutes.
Like a timer that runs down when they go offscreen, but when they are on my screen again the timer stops and restarts when they are offscreen again.