- Home /
Zoom in and zoom out of minimap
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??
Answer by skyfly200-2 · Mar 27, 2012 at 01:42 AM
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.
Answer by rutter · Mar 27, 2012 at 01:42 AM
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`.
Answer by skyfly200-2 · Mar 27, 2012 at 03:35 AM
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;
}
}
thank you for the awesome reply. But how come i will get this error??
Assets/Scripts/cameraFollow.js(119,23): BCE0019: 'orthographicSize' is not a member of 'UnityEngine.GameObject'.
now i get this error
Assets/$$anonymous$$ini$$anonymous$$ap Controls/$$anonymous$$ini$$anonymous$$apSizer.js(22,24): BCE0020: An instance of type 'UnityEngine.Camera' is required to access non static member 'orthographicSize'.
Answer by skyfly200-2 · Mar 27, 2012 at 08:22 PM
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
Answer by williampigmeu · Jul 31, 2012 at 02:06 AM
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; } }
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Creating & accessing a function from a diffrent "OnTriggerEnter" Function 1 Answer
Setting Scroll View Width GUILayout 1 Answer
Very simple script - why isn't it working? 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers