Home

Awesome

preview version in development doc in development

N:ORCA

Optimal Reciprocal Collision Avoidance for Unity

N:ORCA is a Library to add local collision avoidance to your Unity projects. It allows you to create simulations in which you register agents that move toward a goal and avoid each other smoothly without the need for any physic.

NOTE: This package only include the core code of the simulation. Check N:Beacon.ORCA for a user-friendly, out-of-the-box implementation.

Features

N:ORCA is currently in development, and while the repo is available to use and download, there is no documentation yet. It supports moving agents, static agents (dynamic, circle-shaped obstacles), as well as polygonal obstacles. Simulation is implemented using Unity's Job System & Burst, meaning it's relatively fast. The simulation occurs on a planar coordinate system (by default XY), though it can be used for 3D projects (XZ) as well.

Notable features :

High level concept

The basic principles are similar to classic physics approach, where entities are registered to a simulation as either static (obstacles) or dynamic (agents). The simulation is updated each frame with a specified timestep, and dynamic agents are updated accordingly.

Be aware this is not a pathfinding solution on its own, and will yield best results when combined with either A* Pathfinding or Vector Fields.


Hows


Installation

To be used with Unity's Package Manager.
Git Dependency Resolver For Unity must be installed before in order to fetch nested git dependencies. (See the Installation troubleshooting if you encounter issues).

See Unity's Package Manager : Getting Started

Quick Start

The most straightforward way to setup and use ORCA is by using a ORCABundle<T> object :


    using Nebukam.ORCA;
    using Unity.Mathematics;

    ...

    // Create the "bundle" object, containing all 
    // necessary components for the simulation to run.
    ORCABundle<Agent> bundle = new ORCABundle<Agent>();
    bundle.plane = AxisPair.XY;

    // Add an agent
    Agent myFirstAgent = bundle.agents.Add(float3(0f));
    // Set its preferred velocity
    myFirstAgent.prefVelocity = float3(1f,1f,0f);

    ...

    void Update(){

        // Complete the simulation job only if the handle is flagged as completed.
        if(bundle.orca.TryComplete())
        {
            // Simulation step completed.
            myFirstAgent.velocity // -> simulated agent velocity
            myFirstAgent.position // -> simulated agent position

            bundle.orca.Schedule(Time.deltaTime);
            
        }else{
            // Keep the job updated with current delta time
            // ensuring we are framerate-agnostic
            bundle.orca.Schedule(Time.deltaTime);
        }

        

    }
    

Scene setup

Sample: Setup

The package include a Setup sample showing how to use the library. Note that it does not use models, and instead draw debug visualization in the Editor window.

Infos


Dependencies


Credits

While the core calculations & equations are heavily tweaked, they are based on the famous RVO2 Library.



N:Packages for Unity

PackageInfos
Standalone
com.nebukam.easingN:Easing provide barebone, garbage-free easing & tweening utilities.
com.nebukam.signalsN:Signals is a lightweight, event-like signal/slot lib.
General purpose
com.nebukam.commonN:Common are shared resources for non-standalone N:Packages
com.nebukam.job-assistN:JobAssist is a lightweight lib to manage Jobs & their resources.
com.nebukam.slateN:Slate is a barebone set of utilities to manipulate graphs (node & their connections).
com.nebukam.v-fieldN:V-Field is a barebone lib to work vector fields
com.nebukam.geomN:Geom is a procedural geometry toolkit.
com.nebukam.splinesN:Splines is a procedural geometry toolkit focused on splines & paths.
com.nebukam.ffdN:FFD is a lightweight set of utilities to create free-form deformation envelopes.
Procgen
com.nebukam.wfcN:WFC is a spinoff on the popular Wave Function Collapse algorithm.
Navigation
com.nebukam.orcaN:ORCA is a feature-rich Optimal Reciprocal Collision Avoidance lib
com.nebukam.beaconN:Beacon is a modular navigation solution
com.nebukam.beacon-orcaN:Beacon module providing a user-friendly N:ORCA implementation.
com.nebukam.beacon-v-fieldN:Beacon module providing a user-friendly N:V-Field implementation.

Installation Troubleshooting

After installing this package, Unity may complain about missing namespace references error (effectively located in dependencies). What Git Dependency Resolver For Unity does, instead of editing your project's package.json, is create local copies of the git repo effectively acting as custom local packages. Hence, if you encounter issues, try the following: