A* Pathfinding Project  3.7
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
Upgrade Guide

Upgrading from older versions

Read the respective sections on how to upgrade from older versions

General importing and upgrading tips

If you are having problems upgrading. If you see compiler errors for example Try to delete the AstarPathfindingProject folder in Unity and import the package again. This can help removing old scripts which are not included in the project anymore but since UnityPackages merges directories, they are still there.

If you have problems with some compiler messages saying that some members or functions do not exist in a class. It is likely that your project contains a class with that name in the global namespace. This causes a conflict between the classes. To solve it, the simplest solution is to put the conflicting class in a namespace or just rename it.

The largest changest here are that many things were renamed (to avoid naming conflicts and/or to use a better naming scheme)

  • Node class is now named GraphNode instead of Node (less generic, should introduce fewer conflicts).
  • GraphNode.walkable is now named GraphNode.Walkable (capital W)
    • The same goes for .tags (now named only .Tag), .graphIndex
  • Modifier is now named PathModifier
  • Mathfx is now named AstarMath (to avoid conflicts with other packages)
  • Navmesh based graphs now use TriangleMeshNode as the node type.
  • PointGraph now uses PointNode instead of just a Node.
  • The graphs no longer have the field .nodes, instead use the GetNodes method and pass a delegate. This is because some graphs use other types of storage for nodes than just a linear array ( for performance ).


The RecastGenerator has had a large internal rewrite. The Recast Graph now uses tiles. You do not have to enable them, if you do not, it will continue to work like before. See the RecastGraph documentation for more info.

For coders: it does use mostly the same variables as before. The methods are however slightly different. See the class documentation.

AIPath has had some internal improvements, is is generally more stable. I don't think it should require any large changes to your scripts.

If you have been updating graphs manually outside of any scanning methods, that is, modifying node data like GraphNode.Walkable, then you now need (should) use a new syntax to make sure it is safe. Previously there was nothing that hindered pathfinding calculation to take place while the graphs were updated (for manual updates), this could cause weird situations and odd paths.

AstarPath.active.AddWorkItem(new AstarPath.AstarWorkItem (delegate (bool force) {
// do updating here
return true;

The callback will be called (usually every frame, but could be more often) until it returns true. This is to enable slow updates being spread out over several frames to reduce lag.

You may call AstarPath.active.FlushWorkItems after adding the work item to make sure the update is carried out immidiately.

An alternative way of doing this is.

// Stop pathfinding
// Make sure any multi-frame updates are completed before we start, but don't restart pathfinding just yet
// do updating here
// Since there are no more updates, restart pathfinding
RandomPath and FleePath has had some small changes in parameters. Shouldn't be very hard to see how it should be used.
Basically they now use better randomness and avoids the need for an extra parameter.

The above code will have slightly less overhead (no need to create a delegate), but will force pathfinding to stop immidiately which might cause lag if there are very long paths that are being calculated.

Note that A* Pathfinding Project 3.2 dropped support for Unity 3.4

Syntax has changed a bit for the 3.2.x version to make path pooling as streamlined as possible You might not need to change anything, but if you are creating new paths manually, e.g using:

Path p = new Path (startPoint, endPoint, callback);

You will now need to change that. Path is a now an abstract class, and the basic path which calculates a path from a point A to a point B is now called ABPath. Constructors are not used either instead static Construct methods are used. These will use pooled paths if possible

ABPath p = ABPath.Construct (startPoint, endPoint, callback);

All path types implement Construct methods in a similar fashion.

The vectorPath and path arrays on path objects are now List<Vector3> and List<Node> respectively. This is done so that they can be reused if the path object is recycled.

If you have been getting the closest node to a point with

Node node = AstarPath.active.GetNearest(somePosition);

You will now have to either explicitly cast from NNInfo (which the GetNearest function actually returns) or get the node by the .node field

Node node = AstarPath.active.GetNearest(somePosition).node;

See changelog for more changes.

If you are upgrading from versions earlier than 3.1 your settings for each graph might be lost during the upgrade process. Please back up your project before upgrading (well, if you are reading this notice, I can just hope that you have seen the messages about this on other places)

Note that A* Pathfinding Project 3.1 dropped support for Unity 3.3

If you have written code interfacing with the system, you might need to update it:

The serialization API has changed a bit for 3.1 see docs for new api. Int3 is no longer implicitly convertible to Vector3 so for example if you do something like Debug.Log (someNode.position) You will now have to write Debug.Log ((Vector3)someNode.position

These were the most important changes, for more changes, see the change log. http://arongranberg.com/astar/docs/changelog.php

When upgrading from 2.9x to 3.0 there are a few things you need to do to make it work.

  • Backup your project is always a good idea since 3.0 will not be able to read settings from 2.x
  • Remove the A* scripts in the Assets/Editor folder
  • Remove the Assets/Editor Default Resources folder
  • Remove the Assets/Pathfinding folder
  • Import the 3.0 Unity Package, DO NOT copy the files from another project directly since GUISkins and other assets might get corrupted then
  • All GameObjects which had the Seeker or the AstarPath component attached to them will now show up as Missing Script. You will need to reattach the components to the GameObjects
  • The syntax for path calls has changed a bit
    2.9x syntax:
    seeker.StartPath (fromPosition,targetPosition);
    3.x syntax:
    seeker.StartPath (fromPosition,targetPosition, OnPathComplete);
    In 2.9x the Seeker sent completed paths using SendMessage as a Vector3 array
    3.0 will send a callback using a delegate to a specified function, doesn't matter if the path succeeded or not, it will always call that function except in the case where the path was canceled by a new path call to the same Seeker before the path had time to complete
    //The name of the function can be anything, but it must always have the same parameters (Path) the name of the parameter (in this case p) can vary though
    public void OnPathComplete (Path p) {
    //Check if the path succeeded
    if (!p.error) {
    //Path succeeded
    //The Vector3 path can be got from p.vectorPath (Vector3[])
    } else {
    //Path did not succeed
    //Error info can be got from p.errorLog (string)
    //Worth to note here is that you should never call the Seeker again during the same frame unless you really know what you are doing
    //Since if the path fails, it often returns to the function the same frame which would then call another path call which would be returned the same frame and it would cause an infinite loop which would crash Unity. And in any case you rarely need updates of the path several times per frame
    More info about the seeker's path calls can be found on the Get Started With the A* Pathfinding Project page
  • The syntax for graph updating has changed a bit, see Graph Updates during Runtime