How do I make multiple enemies attack simultaneously?

0 favourites
  • 2 posts
From the Asset Store
Zombie attack is a survival game, where you have 2 types of games: Killer and survival.
  • I have some enemy instances with instances of an object called enemy arm pinned to the enemies. Normally the enemies will keep moving towards the player. When the enemies get close enough their instance variable called EnemyAction is set to "Attack" When this happens the enemy stops moving and the enemy arm's rotate behavior is turned on so that the arm rotates through a very short distance very quickly so that it hits the player and then turned off in a short while and then the EnemyAction is turned back to the default.This set of actions is under the trigger once sub-event. However this does not work for multiple enemies when they are all close to the player. In this case when both enemies' EnemyAction is set to "Attack" one instance of the enemy will attack while the other enemy simply does nothing and keeps its EnemyAction set to "Attack" instead of returning to the default. It also keeps moving straight instead of following the player like it should at default. Then any time the enemies close in on the player again they just keep moving forward. I think this all may be due to the Trigger once sub-event and that I used a Enemy instance variable = "Attack" condition in the root event so the proper set of actions may only occur trigger once for when both enemies are in "Attack" state. I have tried multiple ways to get this to occur once for each enemy in "Attack" state. I have tried the For Each condition for enemies combined with the compare instance variable condition checking for being equal to "Attack" This failed. I have tried to pick all instances of enemies where EnemyAction = "Action" instead of the compare instance variable condition. This also failed. I am not sure how to make this work.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You are right about "trigger once", it cannot be used with multiple instances. There must be some mistake in your code, it will be easier to help if you could post your project file.

    Here is a similar project with multiple attacking enemies I fixed for someone else a few days ago:

    dropbox.com/s/9hf092r0ycwedae/AI%20top%20down%20example1%20with%20Shooting3.capx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)