I'm trying to do some basic optimisation for my endless runner where platforms are destroyed once they leave the play area. I can't use the Destroy When Outside of Layout behaviour because they spawn outside of the layout to give the impression that they're seamlessly scrolling into view. Additionally, my player is continually moving right with a simulated platform behaviour (with a camera which scrolls with it), so the world's X value is continually increasing which makes it hard to determine a specific coordinate value to destroy the platform.
I feel like I'm missing a really simple solution here. I have been able to create an basic anchored sprite which kills the platforms off-screen when they collide with this, but I don't really like this and would rather use something position-based. Ideally, I want to do the same for any other objects/enemies that leave the screen on the left. Any help would be appreciated!
Give them a variable called something like hasBeenOnScreen that's set to 1 when the platform is on screen (Size & Position > Is On Screen) - later have an event that destroys the platform outside of layout if hasBeenOnScreen=1
Alternatively, assuming your player is constantly on the left hand side of the screen fixed in place, you can destroy the platforms when their position relative to the player is -x a certain amount.
Develop games in your browser. Powerful, performant & highly capable.
if Object.X < ViewportLeft(Self.LayerName)-(object.width/2) => destroy
This way the object will get destroyed only if its on the left "off-screen".
Thanks to both of you, I managed to get this working! Cheers!