Hi everyone I need your help. I’m trying to create a waypoint system on a spherical world. That’s what I got. The cubes are waypoints ranging from enemy to player direction. Now I have to make sure that the cubes are placed on the spherical surface. I’m trying to use breast and cosine but missing something to make it work. Here is the code with the drawing
Here I add the various waypoints
![public Transform t1, t2, node, planet;
public int division;
private List<Transform> nodes;
Vector3 direction, nodeDirection;
float dist, result;
void Start ()
{
nodes = new List<Transform>();
dist = Vector3.Distance(t1.position, t2.position);
direction = (t2.position - t1.position).normalized;
for (int i = 0; i < division; i++)
{
result = (dist / division) * i;
//
Transform t = Instantiate(node, new Vector3(GetPos(direction.x, result, t1.position.x),
GetPos(direction.y, result, t1.position.y),
GetPos(direction.z, result, t1.position.z)),
Quaternion.identity) as Transform;
nodes.Add(t);
}
float GetPos(float axis, float result, float player)
{
return (axis * result) + player;
}
}][1]