Hi all,
I wanted to see if anyone has any experience with Aron Granberg’s A* Pathfinding library. I’ve been playing around with it a bit and impressed so far but I wanted to see if anyone knew of a solution to a feature I would like to create.
I’ve created a few scripts to have AI move about on a large XZ plane, however I am curious to see if the library is capable of creating AI that can move along a large XY plane. The idea is to create something like bugs that can crawl along a wall based on a players location.
Any thoughts or recommendations?
Do you want bugs to be able to freely crawl from floor to wall?
If not, then making them move along XY plane should be as easy as flipping the coordinates.
If yes, then you’ll need to either find a way to connect two A* planes, or find a 3D A* implementation.
Well at the moment I am thinking of just having them crawl along the wall first before moving onto more advanced floor to wall.
I’ve tried simply rotating a grid against a XY plane and that has worked out a path. However, the character controller doesn’t seem to move the AI pawn.
Any suggestions around areas I need to consider. For example I think I might be using the Height and Obstacle settings incorrectly.
Why not just rotate the camera so it looks like the XZ plane is a wall?
Going from 2D A* to 3D A* is not a trivial task. Can’t really help there without direct access to the code 
If you need a script that handles movement of an object to a given point, you can use something like the following:
public class Mob : MonoBehaviour {
private float MOVE_SPEED = 1; // movement speed
public Vector3 loc { get { return gameObject.transform.position; }
set { gameObject.transform.position = value; } } // location accessor
private Vector3 dest = Vector3.zero; // destination stored here
protected float dist = 0; // distance to destination
// function tells mob to go straight to p
public void Go(Vector3 p) {
dest = p; // destination saved
dir = p - loc; // full movement vector obtained
dist = dir.magnitude; // distance to destination
dir.Normalize(); // movement vector scaled down to unit vector
}
// executes actual frame-by-frame mevement
// does nothing if dist <= 0, which means destination is not specified or already reached
public void Update() {
if(dist > 0) {
float f = MOVE_SPEED * Time.deltaTime; // distance covered between frames
if (dist < f) { // distance to destination less than distance covered?
loc = dest; // put object on destination
Stop();
} else {
gameObject.transform.Translate(dir * f); // put object f closer to destination
dist -= f; // reduce distance
}
}
}
public void Stop() { dist = 0; dest = loc; } // emergency stop
}
Basically if you want a Game Object with this script to go to point 150,120,5, you have another script call Go function with new Vector3(150,120,5) parameter.