How can I get the bullets to 'self-destruct'

allaboutiweballaboutiweb Member Posts: 42
edited November -1 in Working with GS (Mac)
I am designing a game based on the fantastic demo from Orbz, 'Shoot where touch XY' - http://gamesalad.com/game/3097 - I have also been trying for the last hour and a half to get the bullets to self-destruct when they reach XY but for the life of me can not get it to work.

Can anyone point me in the right direction....please.......

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    You could put invisible walls outside the play area - when the bullet hits the wall, destroy bullet.

    OR you could say 'after 5 seconds - destroy bullet' (depending on how long the max time the bullets stay on screen is)

    Hope that helps!

    QS :D

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

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Destroy behavior.

    Its tough to get a rule to check if it is exactly at a given X,Y then destroy itself. You could check if the velocity of the X and Y are 0.

    Also you can use interpolate behaviors to change the position which should give you the exact point to stop and eventually destroy itself.

    OR you could check the magnitude between its position and the target position(as stored in self attributes) and if is is less than some small number, then destroy itself.
  • quantumsheepquantumsheep Member Posts: 8,188
    CodeMonkey said:
    Destroy behavior.

    Its tough to get a rule to check if it is exactly at a given X,Y then destroy itself. You could check if the velocity of the X and Y are 0.

    You could check if the X or Y is greater than a certain number, yes? That way it doesn't have to be so exact.

    So, if self.position Y > 320 then destroy actor, for example.

    QS :D

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

  • allaboutiweballaboutiweb Member Posts: 42
    Thanks for your help guys. I think I figured it out, at least it gives me the result I want. I added a Timer attribute to destroy the bullet after 3 seconds, but that would still leave the bullet floating in mid air if you selected an XY close to the Spawner, I needed to get the bullet to vanish as soon as it had stopped.

    Sooooo I added another Timer attribute to the Movement rule under the 'otherwise' bit which, 'after' 0.1 seconds destroys the bullet too.

    Once again, thanks for your help guys.
  • quantumsheepquantumsheep Member Posts: 8,188
    Ah - right - I'd only read the title! Sorry! :O

    QS

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

Sign In or Register to comment.