Destroying an actor once it leave the screen

KamazarKamazar Member Posts: 287
edited November -1 in Working with GS (Mac)
Ok, so I still feel a little lost with the attributes, true and false stuff, it just all feels messy and disorganized in my mind. All I want to do is basically have an object destroyed when it's X-location goes over 480 or under 0 and it's Y-location over 320 or under 0. Basically, when it leaves the screen. I have some idea on how to do it, but I'd like a brief walkthrough. Thx :)

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    I don't have time right now to write a detailed walkthrough on this - sorry!

    BUT!!!

    You're very much on the right track. In your actor you want destroyed, just put a rule that says 'when an attribute changes' self position x is greater than 480
    Do that for the rest of the screen limits and make sure the rule is set to 'any'.

    Then add the 'destroy actor' behaviour.

    That should do it.

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

  • butterbeanbutterbean Member Posts: 4,315
    It depends on how you want to set it up, I have it set up this way, but let me know if you have questions:

    So it basically entails using the x and y axis

    In my game, I have enemies flying down from the top of the screen, so I created a rule that once the enemies hit the ground, they are destroyed, so they don't get cycled through over and over (top of screen again)

    (under the actor you want to have destroyed)

    Create Rule: When any conditions are valid:

    When self position Y is less than 0
    Destroy this actor

    You can play around with these numbers depending on where on the screen you want the actor destroyed, or to not reappear

    So if they're spawning from the right of the screen and walking from right to left

    You'd place the same rule only

    If self position X is less than zero, destroy this actor

    Hope this helps!

    ( I also use the constrain attribute to keep actors from spawning in certain areas in the scene, let me know if you need help with that, those go hand in hand)
  • ktfrightktfright Member Posts: 964
    wow...you guys do it like that?... i just make walls that are invisible, that are also right outside the display, and make it so when something collides with it, the walls destroy the actor.
  • butterbeanbutterbean Member Posts: 4,315
    I tried invisible walls, for my particular game it didn't work.

    Also, the constrain attribute helped me to keep enemies within the boundaries of the screen, and not on the borders

    But invisible walls are great too! I plan to use them in future games, it just didn't work in the current one :)
  • KamazarKamazar Member Posts: 287
    Thx, guys. I thought there was an option like that somewhere, just didn't remember it :P And yeah, I did try the invisible wall thing, but being the perfectionist that I am, I want to keep everything as elegant, streamlined and optimized as possible. Having a bunch of rectangles outside the camera's scope just bothers me for some reason. Gonna try out the "attribute changes" function. Thx alot, guys.
  • butterbeanbutterbean Member Posts: 4,315
    I felt the same way about the invisible walls too... if it works the other way, it does seem a little more seamless and less clutter on the screen :)
  • KamazarKamazar Member Posts: 287
    Got it, worked out beautifully. Had to increase/decrease the coordinates where the actor should be destroyed by 35 (actor size is 70) since I didn't want it to disappear halfway across the screen.

    Finally got the basic gameplay down! Now it's time to work on scoring, lives, pausing, then last of all, graphics.
Sign In or Register to comment.