Using Unity NavMesh an agent will always take the shortest path, so if I have a long road with several corners, they will look like robots, and not humans, when going to their destination.
Is there some way using gridgraph in this package to achieve a more human result, where they wont always cut corners and walk along edges? Instead focus more on the center or the road, or even more randomly like a human.
Either you can use a texture like in that video, or you can use a more automatic approach:
Set grid graph => erosion iterations to something like 5.
Enable ‘erosion uses tags’ and set the start tag to Tag 1.
This will mark the nodes right next to the wall with Tag 1, the ones 1 unit away from the wall with Tag 2, the ones 2 units away from the wall with Tag 3, and so on (up to 5 units away).
It seems in ur example ur using them for obstacle avoidance, while I would like to use a similar approach to have them walk on roads, would I use the same logic but inverse? (Or am I misudenrstanding, are the dark blue cells roads?)
It seems this is applied everywhere in you scene, could I limit it to be applied to just the roads?
As you can see the erosion works nicely, however the road (GraphUpdateScene) has the same tag value everywhere, which means the agents will not choose to walk more towards the center, instead they just walk along the edges of the road since they think that is the best path.
What I want is what is in the video above, where the road has higher weights (or tag values) the further out on the road you get.
For that you need to use a texture (or possibly a custom script). You can find a texture option in the grid graph settings near the bottom.
This would be done by applying a high penalty for not walking on roads. Negative penalties are impossible to use with the A* algorithm, but you can use a penalty everywhere else to emulate a negative penalty.
Roads are placed dynamically by the players. From what I gathered using a texture is for static maps.
Is there some sample code anywhere where I can look at applying a texture dynamically to surrounding nodes? i.e when I place a road use the texture to set weights on surrounding nodes.