Hide offscreen entities to save cpu cycles

ABK

Well-known member
Is there any way to do that ? Its labirynth stage with many hedges and i need them spawned all at the same time when level starts but i want to save cpu power, its a bit taxing to have them all.

Over 200 entities and this slows game down because stage is big and theyre spawned with offscreenkill 9999999 , so...
Is there any way to switch them off when they are onscreen but enable visibility when theyre near camera view ?
Something similar to offscreenkill  like offscreenhide could solve that but X and Y needs to be different for some entities, some are wide, some are tall.
I need to adjust this so they wont disappear too soon when half of the image is offscreen and half is not.
Or its just not worth the time and hiding them ( for eg. by switching to animation with frame NONE ) with script wont change much ?
Do entities that are offscreen even tax cpu at all or are hidden anyway when off camera? IS it worth it ?
OR... im doing that wrong using so many entities, but i have no idea how to create this kind of stage with multiple walls that block player and need to be displayed in front of player and behind him, they need to be actual entities in the playfield , not decoration afaik.
32dTt.jpg


 
From my experience having many entities at once, no matter if they are invicible with blank frames and also offscreen, they still eating a lot of resurses if they are too many of them. So make them change to a blank frame when offscreen will not help at all.

So for your situation, since i think you are allowed to move back and forth on this stage, one thing i would do is checking which entities are in same z plane in the entire level and then merge them in to one entity. So this way you could reduce the entity count. And that's the only thing i can think of.

Of course the offscreenkill and spawn the entities on the fly could be the way if you where allowed to walk only in one direction and not be able to walk back and forth freely without "enemies groups waiting" screens. But since this is not the case.. yeah, my advice is still what i said above.
 
bWWd said:

This already happens - entities are not "displayed" if they aren't in view, but their other logic is still there, and it does get expensive once you have a couple hundred on screen. There's really no way around this without creating a whole new type of model with certain parts missing, and that's a massive undertaking. It would almost amount to a rewrite of the whole core engine.

Why not use walls and layers? Looking at your stage, it seems you could get the same effect with careful use of walls and fglayers. I think the wall limit is 100, but walls can cover huge areas and so can fglayers.

DC
 
Back
Top Bottom