So, in a game, I'm implementing enemies, as a lot of games do, as KinematicBody2Ds. For the most part, everything has been going well, but there's one problem: the enemies will still do all they'd normally do, even if they're offscreen. This is of course problematic for two reasons:
- There's no reason in trying to run a bunch of code when offscreen
- For example, if the enemy is programmed to walk forward no matter what, they might fall off a ledge before the player even reaches them, and other things like that
So, how could I just make the enemies not do anything when offscreen?