- Home /
Minimap North Direction
I have managed to make a minimap and rotate the higher camera according to the FPS. Now I need to add an arrow that signals north on the map. The minimap is a rectangular box, so anything that is circular won't work.
Also I need to add pins that are always present on the map; for example to show the place where a hospital is. I can add it to the minimap, but how do I always keep it on the screen even if it is out of the borders of the minimap??
Here is the script I have so far.
var minimapCamera: Transform; var target: Transform; public var height=250;
function Update () { minimapCamera.position= target.position+ Vector3(0, height, 0); //minimapCamera.rotation= new Vector3(0, target.rotation.y, 0); transform.eulerAngles.y= target.transform.eulerAngles.y; }
I know it isn't exactly optimal, but short of writing a very complex $$anonymous$$imap system, there is one simple way to do it... Create a specific Layer of objects that is only visible to your $$anonymous$$imap camera, allowing you to place literally anything in your world that only the camera can see. Like text, pointers, arrows, etc.
Answer by jdean300 · Feb 22, 2017 at 05:46 PM
I haven't tested the solution below, but it seems like it should work to me. This will determine the position of pins on the map.
I assume you can get the direction to the pin from the center position of the map (presumably the player), lets say that is Vector3 pinDirection
. What you need to do is calculate the point on the square border of the map in that direction. First, normalize the direction: pinDirection.Normalize()
. Now scale this vector so that the larger of it's components has the value of the maps dimensions on that axis.
Vector3 pinDirection = // get this somehow
pinDirection.Normalize();
float scaleFactor;
if (pinDirection.x > pinDirection.y) {
scaleFactor = mapDimensions.x / pinDirection.x;
} else {
scaleFactor = mapDimensions.y / pinDirection.y;
}
pinDirection *= scaleFactor;
Vector3 pinPosition = pinDirection + map.center;
This may not work if your map is not square - in that case you can probably multiply the pinDirection components by the ratio of the maps dimensions.
Your answer
Follow this Question
Related Questions
Input Field issue with UI navigation system 0 Answers
How to create a dynamic map in hand of FPS like Far Cry 2 or Firewatch? 0 Answers
How to fix object on the map on unity mapbox? 0 Answers
Prevent MultiplayerEventSystem going to another playerRoot 0 Answers
Any way to define a navigation group with the UI system? 1 Answer