Entities Remove When Off Camera


(TheHuckleberryWill) #1

How would I make my entities remove themselves when they leave the camera?


(Draknek) #2

All Entity objects have a onCamera property that you can access. So:

public override function update ():void
{
	if (! onCamera) {
		world.remove(this);
	}
}

(TheHuckleberryWill) #3

:smiley: That wasn’t my method, but thanks!


(Jacob Albano) #4

It’s really best if you leave your question intact, no matter how simple the solution turns out to be. The whole reason for making posts viewable to everyone is so that future visitors to the forum can find existing solutions to questions they might have asked.