Tutorials - Read this first


#1

Here are some tutorials for using the A* Pathfinding System:

Firstly, make sure you have read the Get Started Guide in the docs
http://arongranberg.com/astar/docs/getstarted.php

A* Pathfinding for RTS or Tower Defense Style Games
quill18 has created an excellent tutorial for getting started with the A* Pathfinding Project. It explains a lot of stuff the above get started tutorial does not cover, so check it out: http://youtu.be/bkCLqPpopvE
This is one of the most up to date youtube tutorials (as of May 2013).

Using the A* Pathfinding Project with AI Behaviors
AI Behaviors package in the forums:
http://forum.unity3d.com/threads/133180-AI-Behaviors-Made-Easy!-(Walker-Boys)

Make A 2D Game With Unity3D Using Only Free Tools
The tutorial uses a quite old version of the A* Pathfinding Project, but it is still relevant even if not everything will match up with the current version of the system.
http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding/

Tutorial in Chinese


Need Introduction Tutorial
#2

Only problem with 2D tutorial, is that it was written before Unity’s 2D support. I think the pathfinding has been updated too


#3

Was just going through the example on the “Get Started With The A* Pathfinding Project” page, and something about the code is off.

You have the ‘Next Waypoint Distance’ set to 3, and in the example this causes the AI to select a node several steps ahead of where it is. For example, at the start of execution, it jumps to node 2 because the previous nodes are within 3 units of the Character Controller.

Since the center of the Capsule is in the middle of the mesh, and the path nodes are on the ground plane (y height of 0) , there will always be at least ~1 units distance to the next node. Standing directly on top of a node it’s closer to 1.07XXX

As is, the example has the AI controlled capsule stopping several units short of the end destination, adjusting the Next Waypoint Distance to 1.09 gets it fairly close, but it never ends up standing on top of the final node. With the distance set at >2, it starts skipping nodes and will drag against obstacles on tight turns - possibly becoming stuck if it’s skipping enough nodes ahead.

The GameObjects I added are all at their defaults, so the capsule mesh is the default 2 high, radius .5 along with it’s controller and collider.

Here’s what it looks like when it tries to navigate around a 1 unit wide wall and gets stuck. The red line drawn is the Vector3 that is being passed to controller.SimpleMove, so it’s the pointing towards the current waypoint. The Next Waypoint Distance is set to the default, 3

This all leaves me a bit confused. Whats the proper way to get this capsule to move over every node, and stop at the end of it’s path rather than stopping short of it’s final waypoint?


#4

Hi

For most games this is what you want. You don’t want it to move exactly over every single node because it simply looks stupid for people to do it. The movement would looks extremely rigid and odd.

The AI you write in the tutorial is not very advanced, so the rest that you mention are legitimate issues with that code, if you want a better prewritten script, check out the included AIPath script.

If you really want it to move over every node, you have to use a Vector3.Lerp between every node in turn. The tutorial does not describe how to do that, but in the next version there will be an included movement script which does that since it turns out to be useful for 2D games where this sort of rigid motion is sometimes desired. I don’t really know when the next version will be out however.


#5

#6

#7