Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

TBS navigator style mini map

Discussion in 'Scripting' started by Piesk, Oct 1, 2013.

  1. Piesk

    Piesk

    Joined:
    Sep 23, 2013
    Posts:
    14
    All of the mini map tutorials out there cover how to make a secondary orthographic camera follow you to give the appearance of the mini map follow your character around the world in an rpg style game.

    What I am looking for is for a tbs (turn based strategy)game, the mini map needs to display a miniature version of the background in proportion to the map size, and have a rectangle depicting what section of the map the main camera is currently viewing. Then allow the player to click on the mini map to have the camera jump to that part of the map in game.

    I tried making an orthographic camera fit to the map size, then have the background and a rectangle on layers only the mini map camera can see, and have rectangle move around with the first camera at its center. But i immediately ran into a design flaw about trying to fit the map size to an orthographic camera, I need to get it to snap to the height and width of the map, but it will only stay rectangular rather than square and can only judge it's size roughly rather than snapping to the correct size.

    Any one have some advice? Many thanks.
     
  2. Wobak

    Wobak

    Joined:
    May 21, 2013
    Posts:
    54
    Unity handles camera dimension really horribly. It changes the aspect depending on the gameviewportsize when the camera is the main one.
    You can set the aspect ratio of your camera by asigning camera.pixelRect new values. pixelWidth and pixelHeight are the values that determinate the camera aspext ratio.
     
  3. Piesk

    Piesk

    Joined:
    Sep 23, 2013
    Posts:
    14
    Thank you may well try that.