How do I make pathfinding not collide with each other?

Get help using Construct 2

Post » Mon Oct 16, 2017 8:12 pm

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
B
4
S
1
Posts: 23
Reputation: 394

Post » Mon Oct 16, 2017 10:48 pm

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.
Mistakes were made.
B
62
S
30
G
134
Posts: 1,976
Reputation: 75,479

Post » Tue Oct 17, 2017 3:13 pm

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
B
4
S
1
Posts: 23
Reputation: 394

Post » Tue Oct 17, 2017 5:40 pm

Mistakes were made.
B
62
S
30
G
134
Posts: 1,976
Reputation: 75,479

Post » Tue Oct 17, 2017 8:10 pm

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.
B
179
S
50
G
208
Posts: 8,722
Reputation: 128,812

Post » Tue Oct 17, 2017 8:39 pm

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.
B
24
S
9
G
4
Posts: 515
Reputation: 4,472


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests