- Home /
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:
Kindly, note that I am asking for some references if somebody has implemented the same before.
Thanks in advance, debs
I'm uncertain what you are asking for. Do you want something like a 2D compass that points at the planet or something else? What do you mean by "3d direction indicator"?
$$anonymous$$SP ($$anonymous$$erbal Space Program, free demo available) has a, i think they call it 'gimbal', which is a sort of free-floating sphere compass with interesting directions marked on it, might be worth taking a look at.
There's also this thing: http://forum.unity3d.com/threads/79163-3D-Radar
which looks pretty impressive, though I haven't had an opportunity to try it myself.
Yeah I already went through
There's also this thing: http://forum.unity3d.com/threads/79163-3D-Radar
Actually, I want an indicator sort of as in a bent arrow preferably which points to the planet.
Thanks for the support!
I'm uncertain what you are asking for. Do you want something like a 2D compass that points at the planet or something else? What do you mean by "3d direction indicator"?
Sorry for the misleading words, probably what I am saying is an indicator which blips everytime whenever the spaceship is out of its course, something like the glowing arrows in Need For Speed.
thanks, d
I did a quick watch of a couple "Need For Speed" videos, and I could not see the indicator. I saw a $$anonymous$$i-map which is very different. You need to be explicit with what you are trying to accomplish. You can point to a video along with a timestamp where the indicator can be found, or you can point to an image, or you can include a drawing with an explicit description of what you are trying to do. There are a lot of different indicators. I've answered questions about four different indicators. Here is one of those answers:
http://answers.unity3d.com/questions/407178/rotate-texture.html
Answer by johnnymoha · Jul 08, 2013 at 06:41 AM
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.
Answer by robertbu · Jul 08, 2013 at 06:57 AM
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.
thanks @robertbu and @johnnymoha for ur replies.
actually I wanted a 2d indicator, but 3d indicator is a good point to start with.
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.
I am confused as to which object the script is attached?
Furthermore, I changed the script to C#[as it might be of help to others]
public Transform tracking;
public Transform center;
Transform pivot;
// Use this for initialization
void 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;
}
// Update is called once per frame
void Update () {
pivot.LookAt(tracking);
}
thanks in advance debs!
The script is attached to pointer. You drag onto the variables 1) the target you want to follow, and 2) a game object to use as the center around which the pointer will rotate. As for 3D, you wrote, "can you explain how to achieve the same in 3d." The original script I pointed you to was a 2D indicator that followed objects in 3D space, so I assumed you wanted a 3D indicator.
yeah, I tried the same and the indicator is stationary and not moving at all.
am using the above code and following settings:
PS : I apologize for the confusion, actually its a mistake on my part that am not able to explain the problem correctly
The Indicator should not be at the same position as the spaceship. It should have some distance away. Position the arrow as you would like it to look when it is indicating something. It doesn't need to be pointing at Neptune to start. It just visually has to look right. The initial distance from the center is used for the distance for the "RotateAround".
So what did you mean you 3D? Did you want the arrow to be a 3D object but to move in a 2D circle?
The Indicator should not be at the same position as the spaceship. It should have some distance away. Position the arrow as you would like it to look when it is indicating something. It doesn't need to be pointing at Neptune to start. It just visually has to look right.
Yeah I tried the same but its not working...only am using a small sphere ins$$anonymous$$d of an arrow.
Ins$$anonymous$$d the indicator is stationary not moving with the spaceship but static in 3d space.
As for the indicator, I meant a circle which is parallel to the plane of the spaceship, encircling it. A small blip moves on this circle.