Docs

Navigation

Sedulous integrates Recast/Detour for navigation mesh generation and AI pathfinding. Agents navigate the world using baked navigation meshes, and obstacles dynamically modify the navmesh at runtime.

Setup

using Sedulous.Engine.Navigation;

protected override void OnConfigure(Context context)
{
    context.RegisterSubsystem(new NavigationSubsystem());
}

Entities that need pathfinding get a NavAgentComponent:

let navMgr = scene.GetModule<NavigationComponentManager>();
if (let agent = navMgr.Get(navMgr.CreateComponent(entity)))
{
    agent.MaxSpeed = 3.5f;
    agent.Radius = 0.6f;
    agent.Height = 2.0f;
    agent.MaxAcceleration = 8.0f;
}

Moving an Agent

Set a target position and the agent will pathfind and move toward it:

agent.MoveTarget = targetPosition;

// Clear target to stop
agent.MoveTarget = null;

Dynamic obstacles that carve out the navmesh at runtime:

let obstacleMgr = scene.GetModule<NavObstacleComponentManager>();
if (let obstacle = obstacleMgr.Get(obstacleMgr.CreateComponent(entity)))
{
    obstacle.Radius = 1.0f;
    obstacle.Height = 2.0f;
}

Next Steps