Collision Between Instances Having Pathfinding

So I’m working on a top-down zombie game similar to boxhead. The enemy should basically chase the nearest player. I have it all done by a distance condition and pathfinding behavior.
The problem is implementing collision between the enemies themselves considering they are instances of a same object. The action separate two objects worked well but it has some issues with the pathfinding object. The enemies blink uncontrollably suggesting that the collision handler and pathfinding is counteracting each other.
Any ideas on how should I implement collision between instances with pathfinding?
Ps. I’ve tried pathfinding with physics behavior but no luck.

Take the zombie pathfinding demo for example. That’s what I want to achieve, but I don’t want the zombies to step on one another. They should collide with each other instead while still moving toward the player.

behaviors: pathfinding and obstacle for zombie !

!
obstacle|690x169

This is my exemple project ! i hope that can help you :wink:

1 Like

I tried your project and put top-down behavior to the player but it also glitches as what I’ve said. The enemies blink randomly when they’re close to each other.
Btw where did you put that pathfinding obstacle behavior? I checked your code and can’t seem to find them.

send me your project for i understand better… no glitch with me… i have just two comportment on zombie ! path findingobstactle, and pathfinding !

Try to put top down behavior in your character and move randomly. You will notice that the enemy will bug when they collide to each other.

i think understand ! i have modify the project ! now that seem very good ! tell me if its what you need :wink:

if you need other things, ask me again :wink:

1 Like

That worked better but there are still some times that the enemies blink and teleport.
I decided to remove the pathfinding behavior and separate objects action then add physics behavior and add manual forces to evade the obstacles.
Physics behavior worked a lot better in handling collisions and so far no blinking stuffs or errors but the problem is manually adding forces for pathfinding which is kinda exhaustive.
This will be a lot easier if we can apply pathfinding and physics behavior at the same time.

okay, i have never use physic behavior… and now, even if its complicated, the result is perfect for you?

Yep. Physics behavior is more precise in handling collisions between objects.

thanks for the project i was looking for that only

1 Like

hi guys i’m working on a similar project to yours. the idea was to create a character chased by zombies.
the problem arises when the zombies collide with each other, the pathfinding does not seem to work correctly.
I noticed that you have solved this problem with physics.
can you explain to me how to do or better attach a small project so that I can understand how to solve this problem of mine?

Hello. It’s been years since the last time I used GDevelop and I’m using Unity now.
For what I remember, what I did was to rotate the zombies to face the player slowly then add force towards where the zombie are looking. Pathfinding was just using areas to alter zombies direction.
I presume that GDevelop still doesn’t support collisions for pathfinding since you have a similar problem like I had.
The best solution I can think of right now is to create an empty/invisible “tracker” object with pathfinding behavior that follows the player. Then create a Zombie that follows that tracker through physics.

TLDR
Create an invisible object that follows the player by pathfinding.
Make the zombie follow that object through physics.


Went back to an old game I had and this is how I did it, it works well. If I remember you need to set the pathfinding destination in the first frame of the pathfinding behavior being enabled or the object will teleport back to its original position before pathfinding was disabled.

thank you so much guys you have been of great help

I don’t need a second object (it will reduce performance) because you can just use the Pathfinidng::NextNodeX/Y() or Pathfinding::GetNodeX/Y(). You can get these positions and steer the object towards it using physics like you are already doing. Pathfinding behavior - GDevelop documentation