Hello!
I want to make my NPCs move randomly but smartly on the map, avoiding collisions when they can.
For now, I have a TileMap for the ground tiles, and an other one for objects that can be placed on top of that (fences, rocks, ...).
I'm good for the part of setting a random destination point, I implemented a flood fill algorithm from the NPC and saved every tiles when it can move to (so I just have to pick a random one in that array).
I tried to use Navigation2D to make NPC move randomly to a position, which works great except it does not handle collisions with my object TileMap.
What would be the simplest way to make NPC "smartly" move to the destination while handling collisions? I have a lot of fences that will block NPCs (animals) from moving, so I can't just make them stupidly move and collide until they find a way.
I've seen some leads like subtracting collision shapes from navigation polygons.
Also, knowing that I already have every tiles coordinates the NPC can move to, I suppose I could build a moving algorithm from that, but I wonder if there is a simpler way of doing what I want...
Thanks!