- Home /
How to find where a navagent will be?
I need to know one of two things about a navagent that is currently walking a path. Either where it WILL be after X more seconds of walking along the path, or where it will be after walking X meters along the path. Either one. Even if it doesn't take collision avoidance into account.
Also, how do I find the length of the path? I see remaining distance, but not total distance. This is really rudimentary stuff for a navigation system so I am sure Unity has it exposed somewhere, I just can't for the life of me find it.
Answer by Ed unity · Apr 16, 2014 at 08:44 PM
You should look at NavMeshPath.Corners (https://docs.unity3d.com/Documentation/ScriptReference/NavMeshPath-corners.html) which can be taken from NavMeshAgent.Path. This is a list of positions and so you could determine how far away the Agent is from each or add distances between them to get the distance to a certain point.
If you would like the total distance, you could just get the RemainingDistance after the first time that you set the Destination and then store that is a variable.