I want NPCs to try and follow roads as much as possible in my game. However roads in my game can be added/moved/removed by the player. Meaning I cant just set a certain penalty on areas that are not roads.
What Iām wondering is, is there some way to create an effect that is the opposite of penalty? i.e makes it MORE likely for the NPC to walk there, then I could put this on the road prefab and problem solved
Hi
To achieve that effect what you do is that you add a penalty to every other part of the world.
Conveniently there is an option in the graph settings for an initial penalty. You can use that and then use a GraphUpdateScene component (or some other kind of graph update) to apply a negative penalty. Alternatively you could in the Seeker component change the default tag (tag 0) to have a high penalty, and then apply a tag to your roads that has a penalty of zero. This will result in a penalty of zero on the roads and a higher penalty everywhere else.
This will slow down path searches a bit because it will need to search more nodes to ensure that it can account for the faster travel on roads.