- Home /
NavMeshAgent: How to set perception radius?
Hi All,
I think I've found something that is not only relevant for me but also other users. I'm working on a simulation where a boat is evading other ships on a river. I'm using the default Unity Pathfinding and obstacle avoidance for now, but the obstacle avoidance is not really meeting my requirements.
Since some ships are travelling way faster than my boat, the boat is occasionally to 'late' to steer away and gets rammed. In other words; the local obstacle avoidance (Unity uses RVO, Reciprocal Velocity Obstacles - not to be confused with RVO2, which is basically OCRA, Optimal Reciprocal Collision Avoidance) kicks in too late to avoid the collision.
Simply put, RVO works by predicting in time and distance, so it sounds logical to be able to tweak both of these parameters, right? (https://en.wikipedia.org/wiki/Velocity_obstacle)
Now I have already found out that there is a setting called NavMesh.avoidancePredictionTime which lets you tune the so called 'time horizon' of the agents sailing around.
I'm wondering, is there also a setting that lets you set something like 'Perception Radius' or 'Sensing radius'? So something to specify the distance in which the local avoidance kicks in?
By the way, yes, I've experimented with agent radius, speeds, navmeshes, etc...
Thanks in advance!
I'm actually not sure about the statement I made earlier; stating that Unity uses RVO, and not RVO2. Has anyone more information about this? The Unity Documentation says: " Unity is using reciprocal velocity obstacles (RVO) to predict and prevent collisions. " - https://docs.unity3d.com/$$anonymous$$anual/nav-InnerWorkings.html
But other sources say something else: " There is a great library out there called the RVO2 library. It has been used in both UD$$anonymous$$ and in Unity. " - https://arongranberg.com/2012/09/local-avoidance-pt-3/
I'm actually a bit confused on why Nav$$anonymous$$esh.avoidPredictionTime is not enough for your problem, since you then have the time and velocity, hence the distance (relative to each agent) of when it should start avoiding.
Also as far as I know there is no way to specify the distance or avoidanceRadius that you seek.
I guess you could just program it yourself if you really need it.
I think you are right, because when I increase the agent's speed, while keeping the same Nav$$anonymous$$esh.avoidancePredictionTime, the circle surrounding the agent visualizing that very horizon gets bigger as well! Thanks for your input. I guess the only variables to play with then are the speed and that predictiontime.
Your answer
Follow this Question
Related Questions
How to make the enemy avoid each other 1 Answer
NavmeshAgent and NavmeshObstacle and Bake don't work with AICar 0 Answers
Unity NavMesh obstacle avoidance? 0 Answers
Instantiating a nav mesh obstacle makes all current nav mesh agents try to walk through a wall. 2 Answers
Enemies using navmesh are bumping each other through solid objects 1 Answer