# Cannot create square Normalized Viewport Rectangle for MiniMap

Hi everyone. I am currently creating my first Unity game, which is pretty much the Car Racing game from the Multiplayer example but with heaps of extra maps and features. I want to create a MiniMap in the top-right hand corner of the screen and so far my Camera object looks like this:

Clear Flags: Depth-only Projection: Orthographic Normalized Viewport Rectangle: X: 0.7 Y: 0.7 W: 0.3 H: 0.3 Script: Spring Follow Camera Generic

I have two questions: 1. How can I make my viewport square without distorting the image. 2. How can I make the players look like small circles instead of weird coloured pixels?

My MiniMap doesn't follow the player, it shows the whole map and that is why the players are only pixels on the map.

THANKYOU!!!!

The normalized viewport coordinates are mapped from the range [0, 1]x[0, 1] to the range [0, Screen.width]x[0, Screen.height].

Say the screen resolution is 800x600, and the normalized viewport rect is (.5, .5, .5, .5) - in other words, the upper-right corner of the screen in normalized coordinates (or maybe lower-right).

When mapped to screen space, this comes out as (x = 400, y = 300, w = 400, w = 300). As you can see, once mapped to screen space, the rectangle is no longer square. In order to get a square rectangle in screen space, you'll need to do the necessary arithmetic to compute a normalized rectangle that will be square once mapped to screen space.

This is off the top of my head and I may very well mess it up, but the following should compute a square viewport that's 1/4 the height of the screen and resides at the upper-right (or maybe lower-right) of the screen:

``````float aspect = Screen.width / Screen.height;
float height = .5f;
float width = height / aspect;
Rect rect = new Rect(1f - width, .5, width, height);

``````

Again, that's off the top of my head, and may or may not correct.

For the 'distorted pixels' problem, I would try layers. Set up the minimap camera to ignore the layer that the actual car models are in. Then, attach graphics to the cars that are in a layer that only the minimap camera will render. The graphics could be (for example) large planes that are always upward-aligned and have some sort of appropriate icon on them. Set up the main camera not to render this layer. The 'icon' graphics will then not be visible to the main camera, but will be visible to the minimap camera. Provided you size them appropriately and use a fairly simple and clear graphic, I imagine this would give you the effect you're looking for.

Another option would be transform the car positions as necessary and render the icons in a different space. (They could probably even be GUI controls if you wanted.)