Hi,
I am using localspacerich AI and recast graphs to create rotated graphs.
I have used these successfully before, but my current use case is slightly different.
Previously, what I have done is this:
//Save old rotation, and set rotation to identity:
lrot = cityworldobj.transform.rotation; //save old rotation
cityworldobj.transform.rotation = Quaternion.identity; //Set the geometry to y-up rotation
cityworldobj.AddComponent<LocalSpaceGraph>();
citygraph = worldmainpath.data.AddGraph(typeof(RecastGraph)) as RecastGraph;
citygraph.forcedBoundsSize = new Vector3(1400, 25, 1400);
//generate graph (asynchronously), and then set rotation back to the correct, non-y-up rotation.
This works great, but for my new use case I cannot rotate the geometry first and then generate the graph, and rotate the geometry back.
So, what I am doing is this:
laigraph = gameObject.AddComponent<LocalSpaceGraph>();
RecastGraph addgraph = mcs.cmd.worldmainpath.data.AddGraph(typeof(RecastGraph)) as RecastGraph;
addgraph.name = "dynamicinteriorgraph";
addgraph.cellSize = 0.25f;
addgraph.characterRadius = 0.5f;
addgraph.maxSlope = 90;
addgraph.forcedBoundsSize = new Vector3(500, 100, 500);
addgraph.mask = lmask;
Vector3 boundscenter = new Vector3(transform.position.x, transform.position.y + 0, transform.position.z);
addgraph.forcedBoundsCenter = boundscenter;
addgraph.rotation = transform.rotation.eulerAngles; //set the graph rotation, this is non-y-up.
Then I generate the graph asynchronously, etc.
The graph in this case is generated correctly, however, the AI cannot traverse it properly. It seems that the localspacerichAI is not rotated correctly.
The AI generates a path on the graph correctly (The green line is correct) however they cannot move toward that path, they either walk through the ground, through the air, or get stuck, so it seems that the localspace graph is not aligned properly.
When I try the above solution with the world oriented to y-up, it works great, so the problem must be with generating the graph while it is rotated.
I understand that this is complex, but can anyone offer any advice here?
I am guessing I need to modify the rotation of the localspacerich ai somehow, but I have tried everything that I can think of, and it still doesn’t seem to move the AI in the correct way.
Thanks!