How to stop enemies from overlapping

  • Hey,

    I got a problem I can't fix and maybe someone got a solution for that.

    I have a player that can walk around (orthographic = zelda like, view from top) and enemies that follow him with pathfinding. My problem is now that if you run in circles the enemies start to overlap and "merge". I want to solve it like this:

    >> If enemy is overlapping enemy stop one of them for one second. <<

    I don't know how to pick the two overlapping enemies out of maybe twenty others on the layout and how to then pick just one of those two so they are not being stopped forever both cause overlapping is still triggering.

    Here is an capx file showing the problem: https://burpsgames.com/shared_capx/foll ... erlap.capx

    Thanks for any help

    Marco

  • You could use 'Pick Nth'. 'Pick instance 0' will pick the first instance involved in the overlapping, and 'Pick instance 1' will pick the second.

    in your case:

    when sprite is overlapping sprite

    system --> pick Sprite instance 0

    Do stuff

    or however you want to accomplish your goal. But you can pick the once involved in the overlap by 'Pick Nth'

  • Hey,

    I didn't know that this causes just involved instances. I though it involves all instances ordered by time of creation.

    I will give it a try

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not as long as you use it within the overlapping as with the overlapping you have limited the amount of objects 'pick nth' will look at.

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