How do I stop sprites from overlapping each other?

0 favourites
  • 8 posts
From the Asset Store
Pathfinding AI
$2 USD
80% off
Units do not overlap each other and use different ways if there are several free ways.
  • Hey, so is there a way to stop my sprites from overlapping each other? I have a basic platform ai that makes them case the player as it comes close enough, however since there are multiple enemies they all will run after the player and overlap with each other. I don't want this to happen. What can I do to stop this?

    I considered making them solid, but that just is asking for problems since now I can jump on top of the enemies and thats not something that should happen. Also get stunlocked in between two enemies.

  • What do you want them to do instead of overlapping, just stop? You could make use of loads of commands, you could use 'if enemy is overlapping player then stop moving', or 'overlapping at offset' if you don't want them to touch the player.

  • I want them to not overlap. So basically, something like, the enemy that is on the left should move one pixel to the left and the one on the right should move one pixel to the right until they are no longer overlapping. I tried to make something like this happen, but the code just didn't work I always just get the sprites try and escape to the same direction. :I

    I don't have problem with touching the player since they start an melee attack that stops them from running when they get close enough. But it just looks so silly when I have 3 enemies running and doing the same attack while overlapping with each other.

    This is my latest failure:

    Sorry if I was unclear in my first post, I don't have a problem with the player overlapping with the enemy I can fix that, but I have a problem with enemy overlapping with another enemy (which is the same sprite).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have a look at

  • I don't think this is the answer for my problem, also since my game is a platformer game, so I have no idea how to even implement that into my game based on that .capx

    My idea to solve this would be to find a way to separate two of the same sprite which are overlapping, and I want the one on the left to move a pixel towards left, and the one on the right to move a pixel towards right. However, I have no idea how this can be done.

    Here is my code if someone has an idea how to solve this on the AI moving code. (Basically it is just simple platformer ai code, move left if the player is left etc... so yeah...)

    https://drive.google.com/file/d/0Bw7sth_-pQTXUHRNQXhSUTdDMDA/view?usp=sharing[/code:3ezjlvdm]
  • littanana I too want to solve this. Usually if I try to make the overlapping enemies move left or right, they both move left or right together and keep going that direction. Does anyone else have any other ideas? Maybe pick the lowest UID?

    Issue: Multiple enemies following player eventually clump up into a small ball rather than side by side. A good example of the desired effect is from Starcraft.

  • Here is a really good example as well:

    https://youtu.be/bovlsENv1g4?t=57s

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