How do I make enemies act on their own?

0 favourites
  • 6 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • Whenever i'm making a top down game, I always run into the same problem with my enemies. One of my games was a top down game with enemies with melee attacks and when two of the enemies attacked at the same time, they'd attack many times (they were supposed to attack every half second but did it much faster than that. In another one of my games the enemies would shoot and it worked perfectly with just one enemy but they all attacked rapidly when I added a few more. Basically I can get one enemy to have perfect attacking mechanics but when I add more enemies it gets messed up. So can anyone tell me how they make enemies attack or why it gets messed up?

  • It's a common problem with picking and system waits and it's more difficult than it first seems to get a bunch of enemies working independently on screen. My approach is to add timers to enemies for any waits and use functions for the attacks.

    So you start a timer of 0.5 seconds on an enemy and say on timer complete, run function attack. However the important thing here is to identify the one particular enemy so you send the enemy.UID through the attack function as a parameter. Then when the attack function is called you use a condition pick enemy by UID, where UID is function.param(0). This ensures that the particular enemy will do the attacking, and the same enemy is picked from timer ended to running the attack function.

  • Very interesting, I’ll try that and get back to you if I need more help. Thank you so much for answering my question!

  • This is what I did and it makes all the enemies shoot

  • Event 5 don't use a system pick but use enemy object, pick by UID function.param(0). Also I'm not sure on that first event with the timer running every tick, it should be triggering once for the enemy when they are in distance, try adding a trigger once or some other method of starting the timer once only.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok so this kinda works. When I get close to one enemy it will work fine, but if I’m next to two enemies neither of them fire. When I get close to the enemy with the UID 0 then move out of range it continues to shoot.

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