Destroying Objects Off-Screen At A Specific Point

0 favourites
  • 4 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • 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.

  • 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".

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks to both of you, I managed to get this working! Cheers!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)