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

There are multiple movement scripts in this package. The FollowerEntity is a single component can be used as a pretty close replacement. If you use one of the other included movement scripts, the movement and path calculations are split into two components: the Seeker, which calculates paths, and a movement script that follows the path ( AILerp/ AIPath/ RichAI/your own)

Off-Mesh Link component

The NodeLink2 component

NavMesh Obstacle

The NavmeshCut component is closest analogue, 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 package and this package both have local avoidance, and they work in a similar way.

If you are using the FollowerEntity movement script, it's built-in, like with Unity's NavMesh Agent. If you are using another movement script, it is handled by a separate component called the RVOController. You attach the RVOController to an object which already has a movement script to make it use local avoidance.

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.areaMask

Seeker.traversableTags or FollowerEntity.pathfindingSettings.traversableTags

NavMeshAgent.avoidancePriority

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

NavMeshAgent.CalculatePath

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

NavMeshAgent.currentOffMeshLinkData

FollowerEntity.offMeshLink (not available for other movement scripts)

NavMeshAgent.desiredVelocity

IAstarAI.desiredVelocity

NavMeshAgent.destination

IAstarAI.destination

NavMeshAgent.stoppingDistance

FollowerEntity.movementSettings.stopDistance, RichAI.endReachedDistance, AIPath.endReachedDistance

NavMeshAgent.GetAreaCost

Seeker.tagPenalties or FollowerEntity.pathfindingSettings.tagPenalties

NavMeshAgent.hasPath

IAstarAI.hasPath

NavMeshAgent.isOnOffMeshLink

FollowerEntity.isTraversingOffMeshLink (not available for other movement scripts)

NavMeshAgent.isPathStale

FollowerEntity.hasPath will become false when the path is stale (not available for other movement scripts)

NavMeshAgent.isStopped

IAstarAI.isStopped

NavMeshAgent.Move

IAstarAI.Move

NavMeshAgent.nextOffMeshLinkData

IAstarAI.GetRemainingPath(List<Vector3>,List<PathPartWithLinkInfo>,bool) can be used to get all off-mesh links in the path, if you use the FollowerEntity or RichAI movement scripts

NavMeshAgent.pathPending

IAstarAI.pathPending

NavMeshAgent.Raycast

AstarPath.Linecast. See Detecting obstacles along a line

NavMeshAgent.remainingDistance

IAstarAI.remainingDistance

NavMeshAgent.ResetPath

IAstarAI.SetPath(null)

NavMeshAgent.SamplePathPosition

There's no direct analogue, but it can be calculated using IAstarAI.GetRemainingPath

NavMeshAgent.SetAreaCost

Seeker.tagPenalties or FollowerEntity.pathfindingSettings.tagPenalties

NavMeshAgent.SetDestination

IAstarAI.destination

NavMeshAgent.SetPath

IAstarAI.SetPath

NavMeshAgent.speed

IAstarAI.maxSpeed

NavMeshAgent.updatePosition

IAstarAI.updatePosition

NavMeshAgent.updateRotation

IAstarAI.updateRotation

NavMeshAgent.velocity

IAstarAI.velocity

NavMeshAgent.Warp

IAstarAI.Teleport

See

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