Migrating from Unity Navigation

Guide to help you migrate from Unity Navigation to the A* Pathfinding Project.

In this guide, you will learn what Unity components correspond to which A* Pathfinding Project components and what major differences there are.

Feature comparison

If you are looking for a comparison between Unity's pathfinding and the A* Pathfinding Project, you might be interested in this page: Feature Comparison.

Architectural differences

The overall architecture is not too different; in both packages there are:

  • Movement scripts, which tell the agent how to move and where it should move.

  • Graphs, which describe where an agent can move.

  • Temporary obstacles, which cut holes in the navmesh or update it in other ways.

  • Off-mesh links, which allow an agent to move or jump between otherwise disconnected parts of the navmesh.

However, the names used differ between the packages.

Unity

A* Pathfinding Project

Navigation Window

The AstarPath component

NavMesh Agent component

The movement and path calculations are split into two components in this package. One is the Seeker, which calculates paths, the other is a movement script ( AILerp/ AIPath/ RichAI/your own)

Off-Mesh Link component

The NodeLink2 component

NavMesh Obstacle

The NavmeshCut component is closest, but there are also other kinds of obstacles and ways to do graph updates in this package. See Graph Updates during Runtime.

Graph settings

Unity has a single graph type which automatically generates a navmesh. It is very similar to the RecastGraph in the A* Pathfinding Project. If you create a recast graph in this package, its settings will most likely seem familiar to you.

This package has several other graph types, however. For example, grid graphs, point graphs and navmesh graphs.

See

Read more about other graph types here: Graph Types.

Local avoidance

Unity's NavMesh Agent has local avoidance built-in. In this package, local avoidance is instead handled by a separate component called the RVOController. If you attach it to an object which already has a movement script then it will be picked up automatically, and local avoidance will work much like it does with Unity's package. You will also need a single global instance of the RVOSimulator component, which handles all the calculations and has the global simulation settings.

See

Read more about local avoidance here: Local Avoidance.

AI Properties and methods

When interacting with a movement script, the names again differ between Unity's package and this package. Here's a list of the most used properties/methods and their corresponding properties/methods in this package: The IAstarAI interface is referenced here, which is an interface that all movement scripts (e.g. AIPath/ AILerp/ RichAI) implement.

Unity

A* Pathfinding Project

NavMeshAgent.destination

IAstarAI.destination

NavMeshAgent.SetDestination

IAstarAI.destination

NavMeshAgent.speed

IAstarAI.maxSpeed

NavMeshAgent.Warp

IAstarAI.Teleport

NavMeshAgent.ResetPath

IAstarAI.SetPath(null)

NavMeshAgent.SetAreaCost

Seeker.tagPenalties

NavMeshAgent.GetAreaCost

Seeker.tagPenalties

NavMeshAgent.Raycast

GridGraph.Linecast(Vector3,Vector3) or NavmeshBase.Linecast(Vector3,Vector3)

NavMeshAgent.CalculatePath

IAstarAI.SearchPath, but take a look at Searching for paths for more info

NavMeshAgent.areaMask

Seeker.traversableTags

NavMeshAgent.avoidancePriority

RVOController.priority, but the range is reversed (0 is the lowest priority)

NavMeshAgent.desiredVelocity

IAstarAI.desiredVelocity

NavMeshAgent.hasPath

IAstarAI.hasPath

NavMeshAgent.isStopped

IAstarAI.isStopped

NavMeshAgent.pathPending

IAstarAI.pathPending

NavMeshAgent.velocity

IAstarAI.velocity

NavMeshAgent.Move

IAstarAI.Move

NavMeshAgent.SetPath

IAstarAI.SetPath

See

IAstarAI for more properties and methods on the movement scripts, and Seeker for more settings related to the path calculation.