Pathfinding on spherical planet

#1

I have already bought pro version, but i do not know how to pathfinding on spherical planet like earth.

I don’t know how to do this?

Is there a demo scene i can study?

#2

@aron_granberg

Help?

#3

I want Navmesh Graph to do this.

#4

#5

Is there a video lesson to teach me?

#6

Hi

There is no official support for this at the moment. You have probably already found the main thread about it here in the forum, and that’s the full extent of it at the moment. In there you will find instructions to download the spherical beta at https://arongranberg.com/astar/download (click the ‘Show older versions’ dropdown).

#7

Now I have problems about ai, how to move player on spherical planet in version 4.1.12.

@aron_granberg

#8

How to make the script work in pro version 4.1.12.

``````/** Example AI for Example scene 18.
* This AI aligns itself to whatever node it is standing on (navmesh graphs only)
* which makes it possible to use it for things like spherical worlds.
*/
public class AIArbitrarySurface : AIPath {
Vector3 interpolatedUp = Vector3.up;

protected override IMovementPlane MovementPlaneFromNode (GraphNode node) {
var forward = Vector3.Cross(Vector3.right, interpolatedUp);

return new GraphTransform(Matrix4x4.TRS(Vector3.zero, Quaternion.LookRotation(forward, interpolatedUp), Vector3.one));
}

protected override void Update () {
base.Update();

tr.position = RaycastPosition(tr.position);
}

/** Find the world position of the ground below the character */
Vector3 RaycastPosition (Vector3 position) {
RaycastHit hit;
var normal = interpolatedUp;

if (Physics.Raycast(position + tr.up*0.5f, -tr.up, out hit, 2f, groundMask)) {
normal = hit.normal;
position = hit.point;
}

// Use the node surface as the movement plane
interpolatedUp = Vector3.Slerp(interpolatedUp, normal, 4*Time.deltaTime);
return position;
}
}``````

#9

@zzq