Multiple Enemies with Actors Following

SnakeKiller

  • Posts: 29
I don't know the best approach to this, but I want to create an enemy with blades spinning all around it. That way the enemy can chop the player to pieces, and the player can defeat it using a ranged attack. I have two actors for the enemy. The first one is the main guy that moves around and takes damage. The second actor, is a bunch of blades spinning around the guy. Basically, I have the second actor follow the first one by setting it to the same position as the first one. It works fine ,  but when I place more than one enemy in the scene, the second actor only follows one of the guys. I understand why, it's because it's applying to every actor of type.

Does anyone know a better approach?

This is what I used on my behavior I created (pseudo code):

Code: [Select]
When Created
{
create(Blades) at (x of self, y of self) at (front);
}

Always
{
  for each(actor of type:Blades)
  {
  set x to x of self for actor type;
  set y to y of self for actor type;
  }
}

SnakeKiller

  • Posts: 29
This is probably easier to read: :P

When Created:


Always:
 

stefan

  • *
  • Posts: 2263
Since this is a Actor Behavior, you can just create an actor attribute (lets call it bladeActor), and assign the last created actor to that attribute right after you have created the blade. Then instead of using the loop, just set the x and y of that actor attribute to whatever you had in your loop =)

Good luck!

SnakeKiller

  • Posts: 29
Thank you! I fixed it, and it works fine now! :D