RVO delta always zero

Hi, there. I’ve just started using this addon in a project and am having good results with the pathfinding portion on my point-graph, but have been having some growing pains trying to implement the local avoidance. I’m basically trying to blend the “Getting Started” movement script example and the custom RVO example, but the RVO delta always comes up zero. I have an RVO simulator in the scene, and AI has an RVO controller attached. I set “Collides With” to nothing just to make sure collision detection wasn’t restricting movement. Advice appreciated.

using UnityEngine;
using Pathfinding.RVO;
using System.Collections;
using Pathfinding;
public class AstarAI : MonoBehaviour
{
Transform target;
private Seeker seeker;
public Path path;
public float speed = 2;
public float nextWaypointDistance = 3;
private int currentWaypoint = 0;
public float repathRate = 0.5f;
private float lastRepath = float.NegativeInfinity;

RVOController controller;
void Awake()
{
    controller = GetComponent<RVOController>();
    seeker = GetComponent<Seeker>();
    target = FindObjectOfType<Player>().transform;
}
public void OnPathComplete(Path p)
{
    if (!p.error)
    {
        path = p;
        currentWaypoint = 0;
    }
}
public void Update()
{
    if (Time.time > lastRepath + repathRate && seeker.IsDone())
    {
        lastRepath = Time.time;
        seeker.StartPath(transform.position, target.position, OnPathComplete);
    }
    if (path == null)
    {
        // We have no path to follow yet, so don't do anything
        return;
    }

    if (currentWaypoint > path.vectorPath.Count) return;
    if (currentWaypoint == path.vectorPath.Count)
    {
        currentWaypoint++;
        return;
    }
    float step = speed * Time.deltaTime;

    //Local Avoidance
    controller.SetTarget(target.position, 10, 12);
    var delta = controller.CalculateMovementDelta(transform.position, Time.deltaTime);
    print(delta);
    transform.position = transform.position + delta;

    //transform.position = Vector3.MoveTowards(transform.position, path.vectorPath[currentWaypoint], step);

    if ((transform.position - path.vectorPath[currentWaypoint]).sqrMagnitude < nextWaypointDistance * nextWaypointDistance)
    {
        currentWaypoint++;
        return;
    }
}

}

I feel it’s also worth mentioning that the point graph is an abstract shape. Is it possible that the RVO simulator is unable to calculate collisions when the curvature of the path is too great?

I can confirm that the y axis movement is what’s confusing it. On a flat surface it works just fine, but it won’t move in the y direction on curved surfaces. Is there any way around this? Also, the RVO controller does not seem to rotate with the AI transform on the x or z axis. Is there an option for turning on rotation that I’m not finding?

After a lot of playing around with it, I’ve pretty much come to the conclusion that the RVO system isn’t good for local avoidance on anything but a flat plain. Someone please correct me if I’m wrong about that.

So I’ve been playing around with setting nodes to “Unwalkable” as an alternative, but this also seems to have an issue. There doesn’t really seem to be a way to set a node to unwalkable for everyone but the character setting it. Ideally, you’d be able to set the next node you are approaching to unwalkable for everyone else so that it doesn’t become occupied while you are approaching it, and then set it to walkable as you are leaving it. But if there is a good way to do this, I can’t find it. Does anyone have a recommendation on how to pull this off?

The RVO algorithm is done in a plane. It has some handling of y coordinates to make sure agents on e.g. different floors of a building don’t interact, though. Any movement along the y coordinate is expected to be handled by the movement script (e.g. using a ground raycast or something). It will always return a value in the XZ plane (assuming the RVOSimulator is configured to use the XZ plane, which is the default).

The RVO algorithm does not know about or requires the concept of rotation. If you want your agent to rotate, then that’s the responsibility of the movement script. The built-in movement scripts (e.g. AIPath/RichAI) rotate towards the direction the agent is moving usually.

There are some helper scripts for that related to turn based games. See Utilities for turn-based games - A* Pathfinding Project

Hi, Aron. Thanks for the response. With regards to blocker utility, I was under the impression from reading the documentation and a few other threads on the subject that this wasn’t a good solution for games involving real-time movement and blocking at the same time. To be clear, I’m looking for enemies moving simultaneously to avoid each other. Is there a good built-in utility for achieving this on curved surfaces?

Nothing better than RVO I’m afraid.

Do you have a curved surface like a sphere or something?

Ok, thanks for that. Yeah, working on an irregular sphere. I tried the beta sphere version of you add-on, but it doesn’t appear to work on the new version of Unity. I appreciate that this project wasn’t originally intended for use on wrap-around surfaces like that, but it’d still be cool to find a way to make it work. I’ve found some previous threads discussing this, but much of what’s discussed is either too vague or just over my head. Still, the pathfinding itself works extremely well. I keep thinking there has to be some really simple trick I’m missing to make local avoidance work, but I guess it’s just a lot more complicated than I expected haha. Either way, I appreciate your help.

Hi

For a RVO on a curved surface you will need to do some extra things.
More specifically, you should, on every frame, set rvoController.movementPlane to the plane the agent is moving in at the moment (locally, every point on a sphere still looks like a flat plane). You can check out how the AIPathAlignedToSurface script does it.