How do I make pathfinding not collide with each other?

0 favourites
  • 6 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • So I have this pathfinding "enemies" that follow the player around as soon as he gets into their line of sight. So the pathfinding is meant to make enemies follow the player without colliding with any walls, but they do collide with each other. For example, if 4 or more enemies are following the player, instead of going in a line, they just go throught each other and it almost seems like there's only one enemy following the player as they are overlapping. I tried adding the enemies the "solid" behaviour, but this way they just stay put where they are as they see themselves as obstacles, also tried making the custom obstacles but still doesn't seem to work.

    Is this possible to achieve in any way? Thanks in advance <3

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is a question that comes up pretty often. If I recall, using custom movement push out solids is a pretty common solution, as well as applying physics to the objects in question. R0j0hound also had a nice SAT implementation that works well on circular objects.

    Otherwise, a low cost solution some people utilize is to actually allow overlap during movement, and then have them push each other out of the way upon reaching the destination (StarCraft zerglings).

    Generally speaking there is no easy quick answer for this as far as I know. Even StarCraft had trouble with dragon/Goliath pathfinding and collisions.

  • Well I actually tried doing what you said with physics, but doesnt seem to work, if I put this behaviour the enemies will just still overlap and get pushed away every now and then, not really what I was looking for :T

  • Try Chupmunk physics

  • For each tank call timer "move" with time loopindex*0.10

    tank on timer move, find path to x,y

    It aso helps to make the xy a random area around the coordinates.

  • A trick I used with reasonable success (originally suggested by someone else on the forums) was to have to have an invisible object per enemy do the pathfinding, give the enemy object physics behaviour and move it towards its partner invisible object.

    You pause the invisible object from moving if the distance between it and its partner enemy becomes too great, allowing it to catch up.

    The physics behaviour allows the enemies to bounce off each other without overlap.

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