Help requested with simple spherical pathfinding


I have been trying to create simple pathfinding on a perfect sphere in Unity 2020.3.

I used a NavmeshGraph with a sphere mesh and wrote a simple script for movement.
Everything works in the editor, but in a build the graph has 0 nodes in its array, resulting in my AI not finding a start node.

I made a 200 unit wide Polyhedron in blender, put it in the Resources folder, made sure it has the same name as the mesh and used said mesh on a Navmesh graph like this.
I deactivated Nearest node queries in XZ and Recalculate Normals because both seemed bad for spherical pathfinding.
I also had to activate ASTAR_RECAST_LARGER_TILES under Optimization because my boy is big.

All objects that exist on the globes surface constantly re-orientate themselves using this method:

static Vector3 center; // Always set to the globes position
static float radius; //Always set to globe radius.

 public void Orientate(Transform subject)
        Vector3 subjectUp = (subject.position - center).normalized;

 subject.rotation = Quaternion.FromToRotation(subject.up,subjectUp) * subject.rotation;
 subject.position = (subject.position- center).normalized * radius;

There is no gravity, instead their distance to the center is set to the radius. I used this script based on the example movement script from the documentation to get it to move:
I did not change much except for the very end.

public class AstarAI : MonoBehaviour
    public Seeker seeker;

    public Transform targetObject = null;
    public Vector3 targetPosition;

    public Path path=null;
    public bool reachedEndOfPath;
    public float speed = 3;
    public float reconciderPathTime=0.5f;
    private float nextWaypointDistance = 3, reconciderTimer;
    private int currentWaypoint = 0;

    private void Awake()
        seeker = GetComponent<Seeker>();
        targetPosition = transform.position;
    public void Start()
        seeker.StartPath(transform.position, targetPosition, OnPathComplete); //I also do this every 0.5 seconds.
    public void OnPathComplete(Path p)
        if (!p.error)
            path = p;
            currentWaypoint = 0;
    public void FixedUpdate()
        if (targetObject)
            targetPosition = targetObject.transform.position;

        if (Globe.time > reconciderTimer&&!stop)
            reconciderTimer = Time.time + reconciderPathTime;
            seeker.StartPath(transform.position, targetPosition, OnPathComplete);
        if (path == null) return;

        reachedEndOfPath = false;
        float distanceToWaypoint;
        while (true)
            distanceToWaypoint = Vector3.Distance(transform.position, path.vectorPath[currentWaypoint]);
            if (distanceToWaypoint < nextWaypointDistance)
                if (currentWaypoint + 1 < path.vectorPath.Count)
                    reachedEndOfPath = true;
        var speedFactor = reachedEndOfPath ? Mathf.Sqrt(distanceToWaypoint / nextWaypointDistance) : 1f;
        Vector3 dir = (path.vectorPath[currentWaypoint] - transform.position).normalized;
        Vector3 velocity = dir * speed * speedFactor;

//Here is where I made some changes, deciding not to use the rigidbody.
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.FromToRotation(Vector3.forward,dir), 4*Time.fixedDeltaTime);

        transform.position += velocity * Time.fixedDeltaTime;

And soon my entity was joyfully moving all around the globe and avoiding obstacles set by Navmesh cuts when I play the scene in the editor.

When I build the project it stops working.
The entity can’t move because it can’t find a valid start node close to the target.
My entity sits right on the spheres surface so this can’t be it.
I investigated and found out that my NavmeshGraph still exists in the build but has 0 Nodes in its array, resulting in the first attempt to get a close node always failing for obvious reasons.

Something similar happens in the editor when I just remove the mesh from the Pathfinder, so I figured it’s the same problem in the build. Does it loose the mesh reference from the Resources folder? Is it because the mesh is so big? Do I have to change anything in the settings because of a presumed upwards?
Why would any of this happen in the build only?

I tried setting the mesh myself via script at runtime before manually scanning the graph, but I can’t figure out how access it via code.

I am not an experienced programmer yet and many of the conversations in this forum regarding spherical pathfinding are still very complicated to me.


Are there any known issues like this anybody had with spherical pathfinding on big Meshes?
Does anybody have a hacky workaround that would allow me to set the mesh or even the node list myself to ensure it works?

Even new ways to test for what the issue could be in the build would help.

I have been trying to find a fix for it all week and my brain is smoking.
Any help would be greatly appreciated.

Sorry for the late reply.

You can set it using = ....

It sounds like your mesh might be marked as non-readable or something like that? Do you see any errors in the log?