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 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.