Hello guys, I’m working on a retro sidescroller, and I’m trying to achieve something like the old megaman games, enemies only activate when they are in the screen, and respaw if you move the screen out and came back after.
I tought of a few ways using “OnBecameInvisible()” and “OnBecameVisible()” :
creating conditions on update that are only avaliable when the object is rendered, but that wouldnt completely shut of the object, it would still be checking if its visible or not.
first, make sure your enemies are disabled, enemyGO.enabled = false;
second, I will asume you want them to activate when they are visible on gamescreen based on your methods, you must validate your enemies Visible property with enemyGO.isVisible or enemyGO.Visible, not sure which one, BUT, make sure they are not visible in editor, or game scene, if they are visible in one of them, they are going to be activated, use enemyGO.enabled = true
I made a 2D sidescroller and used this method, took me a little to realize the objects being in editor activated them