Turn-based Utilities

Hi Aron, any update on the turn-based utilities you mentioned in this thread (2D/3D Tile Grid. Moving Agents & occupying a Tile)?

I’m a pro user and would love this feature. I imagine a number of users would be interested in some support also.


I have uploaded a beta version of them.
Use this link http://arongranberg.com/astar/downloads/0/turnbased_Pro_dev
But you will have to change the 0. Go to http://arongranberg.com/astar/download and enter your invoice number, copy the link of one of the pro downloads. You will see that it contains a long alphanumeric string. Replace the 0 in the above link with that string and then you can use the link to download it.

Note that this version does not include all of the new features and fixes from the 3.8.2 version.

Check out the new hexagon example scene.

1 Like

Thanks! I’ll check it out.

I imported the package - I get an error in AILerp…

Error CS1061 ‘StartEndModifier’ does not contain a definition for ‘adjustStartPoint’ and no extension method ‘adjustStartPoint’ accepting a first argument of type ‘StartEndModifier’ could be found (are you missing a using directive or an assembly reference?)


Hm. If you had 3.8.2 installed before, there may be some things that are missing from this version. Try deleting the AstarPathfindingProject folder and import the package again.

1 Like

That was it - I’d imported the turn-based package over the top of an old pro directory.

The sample scene works great - I’m enjoying figuring out how you did it. In my own prototype, I had trouble with the unwalkable flag, and I was about try out a tag-based solution. I’d love to see a tutorial going through the process of setting up that scene.

Just a thought - for development/debugging purposes, I think it would be useful to generate an ID for the hex nodes (e.g. could be generated from it’s world position, giving an ID of 0,0 for a hex at the scene origin). Is there already a way to do this?

Also, the way you’re limiting movement is interesting… I’ve tried setting up turn-based movement on a point graph, basically counting nodes visited and stopping the ai unit when they hit a nodes visited threshold, but your method is way better - better to the extent that I’d replace what I’ve hacked together with your solution wholesale. Nice work!

FWIW, I hesitated before buying the Pro version, but if I’d seen ‘Turn-Based Utilities/support/tutorials’, it would’ve been an insta-buy. Looking forward to seeing more.


I’m glad that you like it :slight_smile:

You can get the nearest node to a position using

var node = AstarPath.instance.GetNearest(somePosition, NNConstraint.None).node as GridNode;

You can then get the x and z indices of the node in the grid using

var index = node.NodeInGridIndex;
var gg = AstarPath.active.astarData.gridGraph;
var x = index % gg.width;
var z = index / gg.width;

The (0,0) node is a node in a corner and (gg.width-1, gg.depth-1) is the node in the opposite corner.

1 Like

@aron_granberg Re: the node blocker code in the hexagon example scene, would that be robust enough to work in real-time? Specifically real-time grid-based movement on a point graph…

It is not meant to be used for unit to unit avoidance when several of them are moving at the same time.
That would require something like cooperative pathfinding which I have been experimenting with here, but it is not ready to be released yet.


Really thanks for this utilities!! But they are still in beta? Do you have any plans to release them?


Yeah, they are still in beta. I do have plans to release them, but they are not ready just yet.

Ok, thanks! Have a nice day!