Direction Indicator

I am making a 3d spaceship racing game with planets, I need some advice in adding a 3d direction indicator to be displayed which gives the direction for the shortest path to the destination planet.

Please help, below is the screenshot of the same:

[12887-image+6.png|12887]

Kindly, note that I am asking for some references if somebody has implemented the same before.

Thanks in advance, debs

You know the position of the destination planet and the spaceship. You also know the velocity vector of the ship. Subtract the ship position from the planet position and you’ll have a vector in the direction the ship should travel. Now you can compare that correct direction vector to the ship’s velocity vector and determine which side of the screen you want the arrow to flash on and how frequently based on the magnitude of the correct direction vector.

By 3D indicator, I assume you want an indicator that will move around your ship in a sphere always pointing at some specific target. First create an indicator arrow. It is best if the indicator is symmetrical around the longitudinal axis and the point needs to be forward (pointing at positive ‘Z’. Position the indicator the correct distance from the ship, and attach this script:

#pragma strict

var tracking : Transform;
var center   : Transform;
private var pivot : Transform;

function Start() {
	pivot = new GameObject().transform;
	pivot.position = center.position;
	var dist = Vector3.Distance(center.position, transform.position);
	pivot.LookAt(tracking);
	transform.position = center.position + pivot.forward * dist;
	transform.LookAt(tracking);
	transform.parent = pivot; 
}

function Update () {
	pivot.LookAt(tracking);
}

In the inspector, drag the game object that you want to track onto the ‘tracking’ variable. Drag the game object you want the indicator to rotate around to the ‘center’ variable.