Enemy Overlapping and Stopping

0 favourites
  • 4 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • Hi all,

    There's a few threads about this but I haven't yet found one that works for me. Here's what I need:

    1. Enemies cannot overlap each other or the player.

    2. Enemies cannot push each other or the player.

    3. If two enemies collide, they can still move if the direction they are facing is clear. Otherwise, the enemy should wait.

    4. One family of enemies needs to be able to walk through solid walls, like a ghost. The player and other enemies cannot walk through that wall.

    My biggest problem is getting a single enemy to stop when two enemies collide. I tried to do this by giving the enemies 8Direction and Solid, but they were pushing each other, and were also clipping through walls at times. Maybe there's a way around this?

    What I've settled on for now is using bullet behavior, and giving them a collision in front, where if the collision overlaps another enemy, the collision's container stops. You can see that in the example. I tried to just say "When enemy collides with enemyFamily, stop enemy", but then I can't figure out how I'd get the enemy to move again.

    Does anybody have suggestions on a better way to do this?

    A secondary question - if you play the capx file, you'll see the enemy jittering. I've found that if I disable the "Set desiredSpeed..." in event 5, then it stops. I have no idea why that actually helps, though. It'll possibly be a moot point if I can get the enemy movement resolved, but it's still strange.

    Here's the stripped-down file as an example: dl.dropboxusercontent.com/u/59414921/testEnemyOverlapping.capx

    Thanks in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I need that info too!

    About 4., you can spawn ghosts on the top layer (above walls, players).

  • Is it important for them to go in set directions? Otherwise you can make them bounce off each other, or have the system change their direction of movement every few seconds. Another way is too have a collision event to make them specificly change there angle of motion to something else if direction is important.

  • Thanks for the suggestions; unfortunately I'm still looking for a solution.

    About 4., you can spawn ghosts on the top layer (above walls, players).

    Is there a particular way to do this? I've always been under the impression that objects that interact with solids will interact with them on all layers. I tried what you suggested and confirmed that they did stop moving when hitting the walls.

    And ry2009, I guess I forgot to mention in my original post that the enemies often or always chase the player, so they need to go in a specific direction and they will also often be interacting with each other. If I have them bounce or change direction it gets pretty jittery quite quickly since they tend to bunch up.

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