Killing an Actor after 5 on screen?

TouchTiltGamesTouchTiltGames Member Posts: 1,162
edited November -1 in Working with GS (Mac)
Ok I've got a gun and it's shooting bullets on the screen, but I want to kill the first bullet shot of the 5 so there's only ever 5 on screen.

So with my limited knowledge, but trying to grasp this: I've setup a Rule and attribute..but then do I setup an interger? I was trying an Attribute like: game.BallCount > 5 then Destroy..but that doesn't seem to work

Thanks in advance!

Comments

  • nulonulo Member Posts: 315
    well. lets say you shoot 1 bullet every second. so, in 5 seconds, you would have 5 bullets on the screen. the problem is, if you continue shooting, you would have 10 bullets in 10 seconds and so on.
    but if you know, that you spawn 1 bullet every second. why not put a timer inside the bullet, that says "after 6 seconds - destroy"
    this way, you would only have 5 bullets on the screen each time.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Hey Nulo, That's a good point, thanks, but this is more of a strategy/physics game where you use the bullet/balls that you shoot to knock stuff over. So you maybe thinking for a bit before you shoot your 2nd shot.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    You know what, your timer idea works just fine..I can set the time to a higher number which would allow the user more "bullet time" hehe. Thanks!
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Ok that's not going to work because of the nature of the game...I need to figure out how to kill the 1st ball I shot of say (5) balls...hmm...
  • nulonulo Member Posts: 315
    but do these "bullets" stop at some point? or do they go until they get off the screen?
    what you could do to not shoot more than 5 bullets at a time would be create a attribute "bullet_num" and give each bullet a change attribute that adds +1 the the "bullet_num"
    then on the spawner of the bullets make a rule, if "bullet_num" is < than 5 spawn bullet
    this way when you have 5 bullets spawned it would not spawn any more until a bullet is destroyed (which you would then do another change attribute to "bullet_num" -1)
    now i have to think a little on how to make the first one get destroyed automatically.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    You need to add a self.integer that is set to 1 when the bullet is first spawned. You need a RULE in the bullet actor that checks for whatever action triggers the bullet spawning to begin with. Every time that action occurs, you need to change the self.integer to self.integer +1.
    The last RULE you need in the bullet is one that checks for when the self.integer exceeds 5; when that happens, destroy.
Sign In or Register to comment.