Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a 3D game in Unity. The primary view is a top-down view, but I am also looking to do target profiles that are true animated versions that reflect the actions of the target. The easiest way to do this, as far as I can see, is to create a second camera, a set offset from my target, facing at it. But how do I show the view from that camera in a small area of the screen?

A possibly related question - how to handle a mini-map? I considered doing this the same way - with a camera fixed high above the character that would show the area around him, but there may be a better way to do this, I'm open to any suggestions.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You're right about creating a second camera, it should work for this purpose (and for minimap as well), you just need to pay attention to its settings:

  • Normalized View Port Rect - use this to set up position and size of the second (third, etc.) camera's rectangle on the screen, all numbers are relative coordinates [0..1]. For example X=0.0, Y=0.8, W=0.2, H=0.2 will render this camera's viewport in the upper left corner.
  • Depth - should be some value larger than the main camera's, in order to render everything on top of the main picture.
  • Culling Mask - may be useful for rendering a minimap. For example, you could assign your level's meshes to some layer, say, "Terrain", and set camera's Culling Mask to render only this layer and ignore all characters and other objects. Or, you could create a smaller and simplified copy of the terrain specifically for minimap purposes, assign it to layer "Minimap", set minimap camera to render only this layer and set all other cameras to ignore it.
  • Clear Flags - depending on your needs, for example "Don't Clear" can be used to render a non-rectangular image (like I did here with a round minimap).
share|improve this answer
    
Thanks, this sounds like what I was trying to achieve. Just to confirm - if I assigned icons to the PC, certain NPC's etc, and have them in the "Minimap" layer too that would show them on the minimap and not in the game world (which is another effect I was wondering how to achieve). Performance-wise, is this a sensible approach? It seems to me that it's only one 3D render, with multiple views, so probably better than trying to separately create those views, but I'm not 100% sure (relative Unity Newbie) –  Ryno Jun 21 '13 at 18:30
    
(Sorry, didn't notice your comment before.) Minimap icons is something I'm only going to implement myself, but your approach seems sensible. Performance should be fine I suppose: those icons should be dynamically batched together into one/a few draw call(s). –  Alexander Konstantinov Jun 25 '13 at 7:24
add comment

The usual way to do this is to use a RenderTexture. You point the camera to a render texture target and that texture updates with whatever the camera sees. This requires Unity Pro. There is an example project here: http://blog.almostlogical.com/2009/12/11/render-to-texture-unity3d/

Barring that, you can set up the second camera to render to a portion of the screen using the rect parameter and set it to a higher depth so it renders in that corner of the screen and after the primary camera. See the reference here: http://docs.unity3d.com/Documentation/ScriptReference/Camera.html

share|improve this answer
    
+1 for the reference link, thanks! –  Ryno Jun 21 '13 at 18:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.