Enemy Health

zNiiCzNiiC Member Posts: 74
edited November -1 in Working with GS (Mac)
I know how to use the destroy actor behavior, but how do I get it to destroy the actor after it collides with the actor about four times?

Comments

  • JPickardJPickard Member Posts: 477
    I'm guessing you create an integer attribute you could name 'hitpoints' in the actor and set it to change that attribute +1 every time it gets hit. And then have another attribute (most probably a boolean) named 'kill' that destroys it after hits = 4.

    I'm sure the pros in the forums can fill that in better, but that's how I'd start playing with it.
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Go into your the actor you want to destroy after it gets hit four times.

    Make an attribute in that actor that is an integer call it hitpoints and set it to 4.

    Then make a rule that says:
    When overlaps or collides with (whatever you want it to collide with when it needs to be hit 4 times)

    Change attribute self.hitpoints to self.hitpoints-1

    Make another rule:
    When attribute self.hitpoints = 0
    Destroy.

    That should work, good luck
  • JPickardJPickard Member Posts: 477
    So, to clarify:

    first: make a GAME attiribute named hitpoints.

    Then make an ACTOR attribute also named hitpoints? Maybe name the actor attribute myhitpoints to cause less confusion? That wouldn't affect it, would it?

    But why make a game attribute at all if it's not referenced in the actor rules?
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    No, just make an attribute for the actor, not a game attribute.
  • JPickardJPickard Member Posts: 477
    ah, figured. ;)
  • zNiiCzNiiC Member Posts: 74
    So it works, thanks! I have a new problem. The actor does not show up during game, but i have it up front, as in i selected layer, move to front. I also put it a background (not the original one), maybe thats the problem?
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Could be, but make sure that the alpha is = 1 which means it's not invisible. :P
  • zNiiCzNiiC Member Posts: 74
    The alpha is one for sure. I can click on it and see it in the editor, but it doesn't show in game.
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Try deleting the one in the game and putting another in there.
  • zNiiCzNiiC Member Posts: 74
    Tried that. Didn't work
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    Watch this video, do everything exactly the same, the same rules apply to player as well as enemys for lives,
    Hope this helps, Jack :)
  • zNiiCzNiiC Member Posts: 74
    That doesn't fix my problem. I already created the enemy lives.
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    Oh sorry, i must have your read your thread incorrectly (btw, i know this sounds like sarcasm but I'm not being sarcastic)
  • zNiiCzNiiC Member Posts: 74
    Yea my enemy is invisible but alpha = 1 and its the top layer
  • zNiiCzNiiC Member Posts: 74
  • zNiiCzNiiC Member Posts: 74
    I got it to work, but I had to start a new project to get the enemy to show up in-game because it didn't show in the last one.
  • zNiiCzNiiC Member Posts: 74
    But I had to restart
Sign In or Register to comment.