How would you limit each weapon to only hit 1 guy?
QuestionMan
Member Posts: 81
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
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.
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...
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.