- Home /
Interface Map
Hey everyone this may seem like a strange question but whats the best way of making a campaign style map that has like some planets on it that can be clicked on and interacted with like in sw:empire at war game? Not so sure how to do it… gui? or maybe make planets of smaller scale like I do in the actually battle scenes?
Answer by drak8888 · Nov 23, 2013 at 03:04 AM
Well since I never really liked GUI in Unity I'd propose making your interface in full 3D using a camera in Orthographic mode if you want more of a 2D aspect to your map. That and using 3D text next to your planet that you activate/deactivate when mousing over your planets for names/descriptions. Then loading the scene you want when you click on the planet, maybe put the scene you want to load in a public variable so you can easily change it from the editor without having to make a thousand scripts for every planet.
If you want something more optimized and less laggy though, you can make planet icons in photoshop/whatever else and put them on planes instead of making full 3D spherical planets.
Unity GUI is a bit messy when it comes to making a menu and makes you code a lot so if you want to keep it simple, make it with 3D objects, but keep the aspect ratio in mind if you're making a PC game (4:3, 16:9, different resolutions might hide some elements of your menu, make sure you design it in 4:3 so everyone can play it)
Hmmm…anyone know what I am talking about? like this? Pic
Can I use a scroll view with a bunch of buttons inside the scroll view that are images of planets that you can click that manage things? How would I place the planet buttons where I want them in the scroll view easily? I would like to stick with gui I think...
Oh well for that you could use GUI for the HUD and put planets in a scene that you could click on to show different things and managmenent options in your GUI, but making the WHOLE thing in GUI would just be incredibly long. If you want to scroll easily between planets, make a camera that you can move around, RTS style.
Yeah well sorry I went to sleep. For the labels you can either use 3dText to show the planet's specs and name or GUIText in your hud. As for the Camera, what I like to do is make an Empty GameObject at the level of the planets, then put the camera inside that gameObject. You can then move the GameObject around and the camera will keep its angle, just make sure the empty GameObject is about in the middle of where the camera is facing. You can then put clamps in your code to make sure your cam doesn't go out limits. I got a simple script I'm using for my own camera which is pretty much similar to what you want :
var accel : float = 10;
var scrollSpeed : float = 20;
var wantedPos : Vector3 = Vector3(0,0,0);
var $$anonymous$$FOV : float = 25;
var maxFOV : float = 60;
var wantedFOV : float = 60;
var currentCam : Camera;
function Start(){
wantedPos = transform.position;
}
function Update () {
// Sets the position the camera should be with the movement keys
wantedPos += transform.right * Input.GetAxis("Horizontal") * scrollSpeed * Time.deltaTime;
wantedPos += transform.forward * Input.GetAxis("Vertical") * scrollSpeed * Time.deltaTime;
// Sets a clamp to make sure the camera doesn't go out of bounds, you might want to change the values
if(wantedPos.x > 100){
wantedPos.x = 100;
}else if(wantedPos.x < -100){
wantedPos.x = -100;
}
if(wantedPos.z > 100){
wantedPos.z = 100;
}else if(wantedPos.z < -100){
wantedPos.z = -100;
}
// $$anonymous$$oves the camera smoothly towards the position it should be at
transform.position = Vector3.Lerp(transform.position, wantedPos, Time.deltaTime*accel);
// Sets the FOV the camera should be at, A$$anonymous$$A zoom
wantedFOV -= Input.GetAxis ("$$anonymous$$ouse ScrollWheel")*30;
// Clamps the FOV to avoid ridiculous values
if(wantedFOV > maxFOV){
wantedFOV = maxFOV;
}else if( wantedFOV < $$anonymous$$FOV){
wantedFOV = $$anonymous$$FOV;
}
// Smoothly shifts the FOV towards the value it should be at
currentCam.fieldOfView = $$anonymous$$athf.Lerp(currentCam.fieldOfView, wantedFOV, Time.deltaTime*5);
}
With this you can move the camera around with WASD or the arrow keys by default, if you haven't changed the axis in the Input. You can also use the scroll wheel to zoom in and out and everything moves smoothly.
Well you can use planes for icons, and put a texture with your icon on it just like the text.