A* Pathfinding Project

Using a Point Graph in 2D


#1

I had quite a lot of difficulty getting the point graph to work in 2D. It kept wanting to be on the XZ axis. I might just be doing something totally wrong, but determined to get it working, I spent a few hours getting to these lines in AIPath.cs:

var graph = AstarData.GetGraph(path.path[0]) as ITransformedGraph;
movementPlane = graph != null ? graph.transform : GraphTransform.identityTransform;

The Point Graph doesn’t work in 2D because it isn’t an ITransformedGraph. It causes graph to be null, which always causes movementPlane to be on the XZ axis. Aron, would it take much effort to make PointGraph an ITransformedGraph?

For those that need a temporary solution, replace the movementPlane line above with:

movementPlane = new GraphTransform(Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one));

#2

Hi

Yeah the PointGraph doesn’t really have an orientation, which is why it is not an ITransformedGraph.
You solution is the correct one, however I do agree that this should be able to be done in a nicer way. I’m just not sure how the UI should look like for that. Do you have any suggestions?
I mean I could add a rotation field to the PointGraph, but it seems strange to have it when it doesn’t affect the PointGraph itself in any way.