Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Pathfinding

as last entry I thought I write a bit about pathfinding, since that is really what was the biggest problem in this game. Game is failing since path finding takes too long in some cases.

I also wanted to improve some.

Basically Building and people pathfinding mostly work, especially people one. With building there comes a problem that in level 3 building might be too far away, in which case pathfinding looks through too many routes.

Weapons especially give problem as they are most likely far away all the time.

When Building tile to target is found, I am simply looking at straightest line to there, since there will never be anything blocking the way in there, so movement to there works fine.

However, with people and weapons I have different approach which i was hoping to improve. Problem was that people and weapon might be behind a building, and straight line would have went through the building. Therefore I need to look actual path to that place. Right now due to lack of time I solved it by target tile being always the tile beside the current one, since even taking straight line to two tiles away, could have resulted in going through a buidling if at cornmer, and i thappend often enough that it didnt quite work as a solution, although from movement point of view had been much better.

When attacking buildings, you notice robots mobe much faster. I am not actually sure why, but it has to do with targeting the tile next to them somehow.

I was planning on getting them to look that when they arrive to next tile, then check the next tile directly which might have prevented this problem, but never had time to do it.

I was also thinking of adding check corner tiles. As now I am only checkin tile to up-down and left-right, not corners, this would have helped too if they had been able to travel to corner tiles.

With attacking people one problem is that robots might go chase one guy if it happens to be closest, instead of bigger bunch of people. I actually meant to continue pathfinding by after looking at target tile, look from target tile 5 tiles away if tile besides it has at least double the amount of people in it, then it would instead be going towards that tile.

That say first tile has 1, next tile has 2, tile besides that 5 people, then i twould target that third tile instead, while shooting along the way. This way robots wouldnt chase loner, buyt go towards bigger amount of people trying to maximise killing.


For the pathfinding I have currently in game, I am otherwise actually quite happy, except for the problem that sometimes it is too slow. But I dont think there was anything sensible to do during the competition time anymore, since everything had took too much time to fix.

I think there had been option at least for weapons, maybe to buildings too that I am now afterwards thinking as good solution to fix the speed problem. Just not sure how long it would take to implement it.

But right now  I am looking for pathway from robot to weapon for example and keep doing it several times during game running.

Instead, it came to my mind now afterwards, that actually since weapons are stable, they dont change their place during game, I should have made a map of each weapon so that I would check distance from weapon to each tile, and then record both distance and pathway to weapon to that tile.

This way robot could look what tile it is in, then access the tile database and see which weapon is closer, if a tie, then pick by random which to take. Anyway, when seeing that weapon A is closest, then check from tiles pathway where he should move next.

This had been very fast way of finding a pathway all the time.

In case a building would get destroyed, then these weapon paths would update themselves by checking the smallest number distance aroung the building, and starting pathfinding starting from that and replacing bigger numbers with smallers, until all are done. This way it could have given one time lag, but likely still much less than with robot, since robots there can easily be doing 50 pathway checks, with weapons they would usually stay less than 10, and even at max i think i had less than 20 weapons.

This had definetily been the way to go had i realised it much earlier.