Best wat to destroy bullets that are off screen?

ShanestaShanesta Member Posts: 63
edited November -1 in Working with GS (Mac)
What is the best way to destroy bullets that are off screen in a scrolable game, the play ares is a good bit bigger that the screen in all directions.

I can think of a few ways to do it, but im not sure what is the most effecient.

It would be nice to have this as an option in the rule section -actor receives event / is offscreen.

Comments

  • CobraCobra Member Posts: 160
    One approach would be to give your bullet actor a "lifespan," for example:

    When self.Time > 3
    - Destroy this actor
  • quantumsheepquantumsheep Member Posts: 8,188
    Another would be to check if its X an Y positions have gone off screen.

    A rule would state something like:

    If self position X >480
    If self position X< 0
    If self position Y >320
    If self position Y< 0

    Then drag in the behaviour 'destroy actor' into the rule.

    Make sure the 'any' option in the rule is on, rather than 'all'.

    If the play area is bigger than the screen, then yes, the timer works well, as outlined by Cobra. It really depends how fast the bullet is moving and how fast the player is moving too. You don't want to be able to follow the bullet and watch it disappear! ;)

    You're right though, it is a tad laborious and can crowd up a rule.

    Hope that helps,

    QS :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

Sign In or Register to comment.