I have create a minimap for my games. But it is too small. It is possible that i can zoom in the minimap to have clear view. Like creating some button to zoom in and zoom out of the minimap??
Yes, you can change the orthographic camera size (sort of the radius of the cameras view). Do this in a script attached to a GUI with buttons. I’m trying to do exactly the same thing, but I do not know how to script that yet (I’m trying to using Antares Universe visual scripting). Ill post again if I find out more.
Here is a link to the documentation for the camera component and the orthographic size value.
Of course. Presumably you’re rendering the minimap with a camera of some sort? If it’s an orthographic camera, you can increase its orthographicSize; if not, you can decrease its fieldOfView.
Here is a script to set the size of an orthographic minimap
If you change the global variable nSize with a button, the camera this script is attached to will scale on any update to the value!
// attach this script to a orthographic camera to set the size to the nSize variable
static var nSize;
function start () {
GameObject.orthographic = true;
// value to set size is global so it can be set from another script
nSize = 40;
GameObject.orthographicSize = nSize;
}
function Update () {
if(!GameObject.orthographic)
GameObject.orthographic = true;
if(GameObject.orthographicSize != nSize)
{
// filter min and max size/zoom limits
if(GameObject.orthographicSize > 100)//min
nSize = 100;//min
if(GameObject.orthographicSize > 1000)//max
nSize = 1000;//max
// set value
GameObject.orthographicSize = nSize;
}
}
here is the package; it has scripts for a slider controlling an orthographic cameras size.
Download it here
No extra Scripting required (except to change sliders position from top right corner)
Variables changeable in Inspector:
- Zoom Level starting point value
- Padding horizontally and vertically(from the top right corner)
- Slider length
- Min and Max values of zoom
to setup:
- add “MiniMapSizer.js” to your mini map orthographic camera
- drag your minimap camera from the hierarchy, onto the cam value of its component
- add “MiniMapControl.js” to you main camera
- drag your minimap camera from the hierarchy, onto the target value of its component
- the settings of the slider are in the “minimapcontrol.js” component of your main camera
Use this script, I made it for my game:
// Minimap Zoom Script
// Author: WilliamPigmeu
// Attach this to a blank GameObject and configure the variables in the Inspector
var minimapZoom = 2;
var maxZoom = 7;
var minZoom = 14;
var Minimap: Camera;
function Start(){
Minimap.orthographicSize = minimapZoom;
}
function Update(){
if (Input.GetKey(KeyCode.KeypadPlus))
if (Minimap.orthographicSize < maxZoom) Minimap.orthographicSize = maxZoom;
else minimapZoom -= 1;
else if (Input.GetKey(KeyCode.KeypadMinus))
if (Minimap.orthographicSize > minZoom) Minimap.orthographicSize = minZoom;
else minimapZoom += 1;
if(Minimap.orthographicSize != minimapZoom)
{
Minimap.orthographicSize = minimapZoom;
}
}