3D Radar: Qustion

I’m attempting to create a 3d radar that works like this.

By detecting gameObjects with the tag “Enemy” that’s with-in X distance from the “Player” and reporting those objects Vector3 positions relative to the player and transposing them on to an off screen camera that is going to do the rendering of the 3d Radar. The second camera has a central point that represents the player will take the Vector3 data and render texture icon(triangles)representations of the gameObjects.

The only thing i cannot figure out is how to render 1 texture, or GUITexture, or gameObject in 3d space per gameObject.

Whenever I try to Instantiate a gameObject it just spams the inspector with clones instead of just 1 per.

I would think that using a texture method would be best, i’m not sure how to draw a texture with a X,Y,Z. Or if it can even be done.

Any Advice is welcome

var EnemyTag : String = "Enemy";
private var EnemyList = new Array();
var Player : GameObject;
private var PlayerCenterPos : Vector3;
private var EnemyPos : Vector3;
private var RadarCenter : Vector3;

//should this be a GUITexture a Texture or GameObject.
var aTexture = some type of game object;

//
function GetEnemyList() {

EnemyList = GameObject.FindGameObjectsWithTag(EnemyTag); 

	for(var ERID : GameObject in EnemyList){
		PlayerCenterPos = Player.transform.position;
		EnemyPos = ERID.transform.position;
		DistanceFRCm = (EnemyPos - PlayerCenterPos).magnitude;
			
			if(DistanceFRCm < 10){
				DrawEnemyRadarID(ERID);
			}
	}
}
//
function DrawEnemyRadarID(ERID){

var PlaceAt : Vector3;

RadarCenter = transform.position;

ERIDpos = (ERID.transform.position - PlayerCenterPos);

PlaceAt = (RadarCenter + ERIDpos);

//how should i do this line of code?
aTexture. render texture to 3d space = PlaceAt;

}

//
function Update () {
GetEnemyList();
}

I wouldnt bother with that approach as it sounds CPU intensive not to mention hard to code

My approach was to add a camera that hovers above the player. You can display multiple cameras in Unity on the same screen. Then its all on graphics and not CPU.

If you want radar effects, you can assign a graphic to your player which is only visible to that camera, like a Gizmo, and the camera simply tracks along, seeing only the radar image versions of the world.

I just added some textures as it was only half complete

These should not be visible in the main camera however I’ve left them on as they show the process, how it works.

Ok i see where your going; looks like i can use Gizmos.DrawIcon. I’m going to work with this and see what i can come up with. Thank you for the advice this is awesome.

Heres some guidelines

  1. make a dot for friendly and enemy in photoshop or gimp, use a black background
  2. place this on your character either in the form of a plane(or use drawgizmo, not sure if it follows character though then) so its a child object
  3. Align it properly and check its visible from above
  4. Use the particles - additive shader(?) so it gets rid of the black
  5. add a camera to your scene
  6. add it as a child of your player, and change its options(depth must be higher than your main cameras depth, and the size)

The camera view should appear superimposed on your main camera at this stage

  1. script/align in world view so that the camera tracks as you want it to(I cant be more specific here in this space)
    8 ) Create a new layer in the layers tab and call it ‘hud’ or similar
  2. Assign all the spots(planes or circle objects you’ve attached) to hud
  3. Camera has an option to set which layers are displayed, change it so that its only displaying the hud layer.

alternative to 1) and 2) - use a sphere(may be slower to render but keeps stable from all angles.

Thanks for all your advice Rman. I’ve gotten my radar up and running using your methods. I’m just trying to do a little something different.

What i would like to do is use GUI.DrawTexture to place an representative icon in place of the object. Currently i can use Camera.WorldToViewportPoint with the results that i want, but for it to work Unity needs to create an instance of the GUITexture for every radar contact in order to place the icon. So i would think that using GUI.DrawTexture would be a better method. I cant seam to get Unity to draw the icons inside the RadarCamera that is overlapping the main camera. I was trying to get WorldToViewportPoint information for the RadarCamera and pass it along to the GUI.DrawTexture, but that did not work out to well. Whats the impact on instancing a GUITexture? If it’s not that big a deal then i can stick with this method.

Or i may have to use the Object method and place the icon onto it. Then have the icon texture change based on the current condition.

The pic below is using the Camera.WorldToViewportPoint method which works great.

I dont know

I would have just, if I wanted your hud there, just made the camera at an angle to the world, placed a script that turns enemy beacons on within range, and placed my replacement icons as I have already done. I cant see what you cant do with straightforward cameras. Am I missing something? You do know that those spots on my main camera are not actually there, this was just on the picture and was left on for accuracy.

Looks great though.

This is exactly what i have. The RadarCamera sits above and behind the player and is a child of the player. The Radar display is also a child of the Player. The targets have a script that enable the LineRenderer and MeshRenderer when with-in range. I was just looking for the best method of rendering the icons to the Radar. My fear was that if the icons were textures on a polygon then the image quality would change based on there position in the game world. Because i want the icons to keep there size and shape i think that drawing a GUITexture to ScreenSpace or GUI.DrawTexture, you’ll get a static image that only moves on the screen X,Y.

I got some more ideas and when i get it. I’ll post it here.

I can only suggest for my method of having the icon on the character, turning mipmaps off.

However your method of drawing them seems better.

Here is a test build you can try out. Joystick needed.

@ForceX:

I developed pretty much the same type of radar system as you are suggesting using the method you are discussing. It worked fine for me when I did ut.