# Creating a rotated graph using Localspacerichai and recastgraph

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

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>();
addgraph.forcedBoundsSize = new Vector3(500, 100, 500);

Vector3 boundscenter = new Vector3(transform.position.x, transform.position.y + 0, transform.position.z);
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!

Hi,

I’m still stuck on this, unfortunately.

The graph is being generated properly, and the green line from the seeker is in the correct place, but the localspacerichAI is not following it.

It is just moving backward and forward, almost like it can’t find the path?

These two images show what is happening:

It is just staying in one spot generating blue path waypoints but not moving toward the green path line.

This system works then the graph is not rotated (But that would mean that I would need to rotate my world to positive y-up, which I can’t do).