- Home /
[SOLVED] NavMeshAgent Create Imperfect Paths? [SOLVED]
Hello, I just started messing around with NavMeshes, and I could not find any way to stop Agents from always finding the perfect, and fastest path to it's 'destination?' Has anyone else had this problem? And has anyone found a method? Thanks :)
Hi, i dont think i understood your question so you dont want the nav$$anonymous$$esh to find shortest path please explain a bit more
Yes, I would like the Nav$$anonymous$$eshAgent to not be perfect, sometimes go a longer way to the destination, and stop all agents taking the exact same route (they always end up in a line -_-) Thanks for responding :) Sorry I didn't see it till now, my internet cut out :(
Answer by tanoshimi · Jan 20, 2014 at 09:17 AM
Interesting question. Unity's built-in NavMesh system, in common with most path-planning algorithms, is designed to efficiently calculate the single least-cost path, according to some definition of "cost". So, if you want different units to calculate different paths, you need to adjust their relative calculated cost of those paths.
Unfortunately, I don't think it's possible to add a random noise factor to path costs at runtime (which is what it sounds like you really want to do). However, one possibility is to ensure your NavMesh consists of lots of different layers (e.g. Road, Grass, Hill, Water etc. etc.) and then assign different per-layer costs for those layers for each agent. Thus, you will end up with units that have a preference to travelling across the "road" layer, some would prefer to go over "water" etc., and they should calculate different least-cost paths accordingly (note that your in-game terrain doesn't actually have to be road/water/grass - it could all be the same surface, but with "invisible" costs to each unit just to artificially create variation).
THAN$$anonymous$$YOU for your answer! I appreciate the time you put in, and what you actually said, it answered my question! AND gave me a way to do it! THAN$$anonymous$$YOU @tanoshimi! :D
Your answer
Follow this Question
Related Questions
How would I simulate a rectangular Nav Mesh Agent? 0 Answers
NavMesh Components for 2017.4.9f1 1 Answer
Weird jumpy motion of character in Navigation Fundamentals proect 0 Answers
Runtime Navmesh not working on mobile build 0 Answers
Put (Instantiate) Gameobject along or accross a path Unity 1 Answer