Hi all,
how do I add a static obstacle so that RVO agents will be aware of it?
Many thanks.
It seems that I have managed to have an RVO agent be aware of a static obstacle but the way the agent tries and avoid it is not satisfactory.
`public class RVOMeshObstacle : RVOObstacle
{
protected override bool StaticObstacle { get { return true; }}
protected override bool ExecuteInEditor { get { return true; }}
protected override bool LocalCoordinates { get { return false; }}
protected override bool AreGizmosDirty ()
{
return false;
}
protected override void CreateObstacles ()
{
float height = GetComponent<Renderer>().bounds.size.y;
Vector3[] verts = GetComponent<MeshFilter>().sharedMesh.vertices;
for (int i=0;i<verts.Length;i++)
{
verts[i] = transform.TransformPoint(verts[i]);
}
AddObstacle (verts, height);
}
}`
I notice that the agent gets very close to the obstacle even if its time horizon is 1.0s for both agents and obstacles.
Also once the agent is very close to the obstacles does not try and avoid it correctly but it tends to get stuck close to it.
EDIT
The agent gets stuck when the desired velocity is perpendicular to the obstacle line, e.g.
I have a box and the agent is requested to go over it, so the expected behaviour is walking around the box, but instead it start rotating in order its velocity to be “parallel” to the box and it gets stuck when its desired velocity is perpendicular to its “expected” velocity that is parallel to the obstacle.
Do I need to tune some other parameters?
Local avoidance is not pathfinding. Local avoidance can solve for local minima, but is very bad at global minimas. In the case that it encounters an obstacle straight on, it has a very hard time figuring out which way to go since it only moves towards the local minima not the global one (which would be to calculate a good path around the obstacle).
What usually works well is to have some additional force for making the agents move away from obstacles. The RVOController has the Wall Avoidance Force (and Falloff which controls how fast it is reduced over distance) which can be used to move away from obstacles.