Hi all, I’m using a radar version from unify wich works perfectly. It draws blips for objects around you by their tags as if you look the scene from above. So, objects above you in the radar are in front of you and the ones down the radar are behind you. I want it to show as if the radar is looking from behind you instead from above, so blips up in the radar are above you and down the radar are below you. Objects centered in the radar won’t be in your same position but just in front of you, as it should work in an Space Game or Flight Simulator. There is the code drawing blips:
function drawBlip(go : GameObject, aTexture : Texture, iconPixels : int){
centerPos=centerObject.position;
extPos=go.transform.position;
// first we need to get the distance of the enemy from the player
var dist=Vector3.Distance(centerPos,extPos);
var dx=centerPos.x-extPos.x; // how far to the side of the player is the enemy?
var dz=centerPos.z-extPos.z; // how far in front or behind the player is the enemy?
// what's the angle to turn to face the enemy - compensating for the player's turning?
var deltay=Mathf.Atan2(dx,dz)*Mathf.Rad2Deg - 270 - centerObject.eulerAngles.y;
// just basic trigonometry to find the point x,y (enemy's location) given the angle deltay
bX=dist*Mathf.Cos(deltay * Mathf.Deg2Rad);
bY=dist*Mathf.Sin(deltay * Mathf.Deg2Rad);
bX=bX*mapScale; // scales down the x-coordinate so that the plot stays within our radar
bY=bY*mapScale; // scales down the y-coordinate so that the plot stays within our radar
if(dist<=mapWidth*.5/mapScale){
// this is the diameter of our largest radar circle
if (iconPixels == iconSize) {
GUI.DrawTexture(Rect(mapCenter.x+bX,mapCenter.y+bY,iconSize,iconPixels),aTexture);
} else if (iconPixels == iconBig) {
GUI.DrawTexture(Rect((mapCenter.x+bX)-((iconBig-iconSize) / 2),(mapCenter.y+bY)-((iconBig-iconSize) / 2),iconBig,iconPixels),aTexture);
}
}
}
How to modify it to draw blips as I explain above?
Thanks in advance!