How would you limit each weapon to only hit 1 guy?

QuestionManQuestionMan Member Posts: 81
edited August 2012 in Working with GS (Mac)
I have a large projectile that hits groups of enemies, but it is triggering the death of more than one actor, how would you limit this to just affecting 1 actor? (ie the first one it hits)

Answers

  • 3itg3itg Member, PRO Posts: 382
    if your enemies are different actors, then just set it up to be destroyed only when it collides with that actor type.

    if your actors are all the same, just a bunch of them, try something like:
    give the game an integer attribute (CountEnemy).
    give the enemy actor an integer self. attribute. (EnemyNumber)
    from the "Home" screen, Actors tab, on the left, add a tag for each enemy (lets say 5 for now, enemy1-enemy5)

    add 2 change attribute behaviors to your enemy
    Change attribute self.EnemyNumber to game.CountEnemy
    &
    Change attribute game.CountEnemy to game.CountEnemy+1

    Now add a rule:
    If self.EnemyNumber = 1
    Change Attribute self.Tags to Enemy1

    if self.EnemyNumber = 2
    Change Attribute self.Tags to Enemy2


    then you can set up your weapon to collide with the actors based on their tags, or their type, depends on how you set up your game.
  • QuestionManQuestionMan Member Posts: 81
    Thanks for that input, is there any simpler way? I only ask because in the future I may have 40-50 enemies on screen, seems like that would be a huge amount of typing
  • 3itg3itg Member, PRO Posts: 382
    edited August 2012
    those instructions cover both instances...
    If you have many actors then use collide by type.
    if you reuse the same actor over and over again, to make 50 enemies, then use the second set of behaviors I outlined.
    The second suggestion would be programmed into 1 actor once.
    When that actor appears, it "Counts" itself and increments an attribute. when the next the duplicate actor appears. it starts as the same as the first one, but then also "counts" itself and increments its number.
    so 1 used twice would become the same thing, except one would use the tag Enemy1. the other would use the tag Enemy2.

    Sorry I can't think of a simpler way...
    But the above should really only take 10 minutes...
  • QuestionManQuestionMan Member Posts: 81
    Does that strategy mean I have to have 50 tags for the same actor?
  • 3itg3itg Member, PRO Posts: 382
    I am not entirely sure on that...
    but I am pretty sure if you want 1 actor to behave like 50 separate actors you are going to have to make 50 of something... whether its 50 rules... 50 tags... or 50 duplicate actors with 1 attribute changed...
    the most efficient method is up to you, I can only offer suggestions.
    I use those methods I outlined in a game I am currently making, they all seem to work great.
    Copying and pasting 50 times may be tedious, but if thats what you consider to be "a huge amount of typing" I probably can't offer any more helpful suggestions.
  • QuestionManQuestionMan Member Posts: 81
    I just like to keep things simple and neat looking. Thanks for the suggestions dude.
Sign In or Register to comment.