How to destroy an enemy after so many hits?

Hi, After several attempts I cant work out what I am doing wrong? I am new to Gamesalad so would appreciate an example.
Here's what I've been doing with no luck

When bullet collides with actor, attribute game.hit to game.hit+1
And then
When game.hit=3, destroy actor

Appreciate an example cheers

Comments

  • -Timo--Timo- Member Posts: 2,313
    if I were you I should use a self attribute.
    but you are thinking in the right way so I don't know why its not working... :/

    make sure its a self.integer attribute. (we call it self.hit)
    when actor overlaps or collides with bullet (not when bullet overlaps with actor)
    change attribute
    self.hit to self.hit+1
    when self.hit = 3
    do
    destroy actor

    hope this helped :)

    -Timo-
  • MacBruvMacBruv Member Posts: 6
    I tried this as well Timo but for some reason it still didn't work :(
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    How fast/regularly do your bullets hit the enemy? It could be that it's misfiring the rule on 3 because the 4th bullet hit it instantly afterwards, so try >= 3

    As @timolapre1998 says use self attributes otherwise you won't be able to have more than one enemy on the screen.
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    A good way to debug things like this is create simple actor - inside that actor use the display text behaviour - give it a colour. Make that text display the game variable 'hit' which is game.hit. If it counts up as bullets hit you know it's working. If it reaches 3, then there's something wrong with the logic in the destroy rule.

    All the best, cheers, M@
  • kolabokolabo Member Posts: 240
    A good way to debug things like this is create simple actor - inside that actor use the display text behaviour - give it a colour. Make that text display the game variable 'hit' which is game.hit. If it counts up as bullets hit you know it's working. If it reaches 3, then there's something wrong with the logic in the destroy
    Good suggestion.

    Or, you can add the display text behavior to your actor. Change the color to one that contrasts with your actor.

Sign In or Register to comment.