Destroy actor when off screen
DerfMilar
Member Posts: 27
Hey everybody!
I'm making an infinite runner-like game, but the obstacles are hand placed in the scene, they never move. The camera scrolls to the right along with the player actor.
Since my obstacle actors don't technically ever leave the scene, how can I destroy them once they've left the screen?
Any help would be fantastic. Thanks!
Comments
There is no real need to destroy them . . . but if you want to or need to destroy them then you can create a rule that checks their position in relation to the camera's position.
I'll let you do the maths, but basically the camera's position is defined by its origin (its lower left hand corner) . . . . so (assuming a horizontal movement):
When obstacle's x position is < than the camera's x origin (plus or minus a value) then destroy.
Great, thanks for the info! I'll give that a shot.