- Home /
Deleting or inactivating off the screen.
Hi, I'm making a 2d platformer which I want to delete the game objects left side of camera since I don't need them. What about the right side of camera in which I have to stop updating or stop instantiating. What's the best solution to this? How do they do in normal 2d games? Do they stop updating?
u can use something like this but Idk if it'll work:
var isSeen : boolean;
function Update(){
if(isSeen){
...
}
Of course isSeen will be in a function where you check for the visible objects
Answer by CeejayZSmith · Mar 01, 2013 at 09:26 PM
you could use this
function OnBecameInvisible () {
enabled = false;
}
function OnBecameVisible () {
enabled = true;
}
this disables the objects that are not in view of the camera and re enable them when they are seen.
Dont use this on moving objects or enemies as they will stop until they are seen
enabled not doing anything for me. I checked with the platform in which I'm checking for the camera borders .