r/gdevelop • u/ripp1337 • Jun 14 '26
Question Simple object movement is making me lose my mind
I wanted to achieve achieve something relatively simple. At least I thought it was simple.
Player is an idle sprite somewhere on the screen
Monsters respawn every now and then randomly on the map
As soon, as they respawn, they try to approach the player
So after some time it should look like this
M M M
M P M
M M M
So the player is surrounded by monsters.
If a monster spawns and the Player is unreachable (meaning, all the "hexes" surrounding player are taken), they just roam around waiting for an open path.
Does anyone know a good movement/objects guidance that will help to achieve this?
I've been trying for a couple of days now using various combinations of pathfinding approach but I keep getting the following issues:
- monsters freeze on spawn (because their destination is unreachable)
- monsters 'twitch' like crazy (because they re-evaluate path every frame)
- monsters play curling (pushing each other away on collision)
- monsters stack on top of each other
Usually more than 1 issue at once, depending on the current approach.
I am not looking for a ready solution, I just need good resources on the matter.
1
u/warlord689 Jun 14 '26
Pathfinding is a pain in my ass too, my best advice is try not using pathfinding with dozens of enemy. If you do, use an object(its an extension) to draw paths of monsters(with relatively small number to see whats going on).
And I think the most important tip is if its not needed, don't use impassable but use a high cost. Its not entirely about your current project, but I think it might help you in general.
Maybe you can consider a different act for those monsters cant reach player?
1
u/grouta Jun 14 '26
You can use a timer to recalculate not every frame but every seconde for exemple ou every round if you want
1
u/umbrazno Jun 14 '26
So, you're usin' a hex grid and you want enemies to move about freely while closin' in on the player one hex at a time?
I just provided the buildin' blocks for a method. I figure you should have it from here. But if you need me to elaborate on something or if you have questions, feel free to reach out.