- Home /
Change navmesh area cost at runtime
Is it possible to change a navmrsh cost at runtime to change how the AI autopaths based on character stats.
For example in my sample scene there is two half's of land divided by a river. Joining the two half's is a bridge on the far side opposite of the character. If the character has high intelligence and high stamina I want to reduce the cost of the bridge and increase the cost of the water. If the character has high intelligence and high swimming I want to increase the bridge cost and lower the water. Likewise if the character has low stats I want them to cost about the same.
More or less I want to autopath based on character stats so that higher stats in specific builds rewards the player in some way by transversing the map differently/quicker.
Is this possible with the navmeshagent?
Thanks for the help.
It's possible with Astar Pathfinding Project by Aron Granberg.
Answer by adriant · Feb 19, 2018 at 01:07 PM
Have you tried modifying the area costs specific to an Agent using NavMeshAgent.SetAreaCost(int areaIndex, float areaCost)
?
Answer by Harinezumi · Feb 19, 2018 at 09:14 AM
Apart from the Astar Pathfinding project mentioned by Cherno, you can also try Unity NavMeshComponents (manual: https://docs.unity3d.com/Manual/NavMesh-BuildingComponents.html).
Your answer
Follow this Question
Related Questions
line in navmesh obstacle 1 Answer
NavMeshAgent wait for rotation before moving 1 Answer
Making NavMesh areas? 0 Answers
NavMeshAgent blocking path 0 Answers