- Home /
RTS minimap (mobile but still taking all ideas)
I am curious how i should go about making a minimap. I want to represent the whole battlefield and units as icons based on type. How would i go about doing this? I know i could have a second camera and then make a gui icon above each object that is only rendered for the minimap camera, but how would i then get them to scale? Would this be inefficient on mobile devices? (tegra 2 tablets)? How would i set up a second camera and render it to a texture anyways? How would i also accommodate for enemies units being same guiIcons, but red instead?
Answer by Tasarran · Jan 25, 2012 at 08:45 PM
That's more than one question, you're disqualified! Just kidding; I'll try to take these in order, I'm working on the same sort of thing myself right now.
In the minimap, your icons would all be the same size, wouldn't they? That's the way I visualize it working. You just create the icons at the size you want. When you display GUI elements, you specify what size they will be.
I can't speak to the specifics of mobiles, I've only been developing for PC/Web so far.
As far as the different icons, I'd just create red versions of the icons at the same time as I made the green ones. If you're using PhotoShop, you can adjust Hue/Saturation/Brightness in one command, and make multiple variations of the same icon. Then I'd use a Skin for each color. You could squeeze as many versions as you want in one skin by using the Custom slots, but if you make one skin and set it up the way you want, you can just Duplicate it and swap out the textures for the icons.
Then, just before you display an element, you can have a command (this is of course, in your OnGUI function):
GUI.skin = GreenIcons; (Or RedIcons)
You can have an if or switch statement to check a variable on the unit to switch between GreenIcons and RedIcons.
hmm, couldn't i modify the icons in code by adjusting color values in unity itself? (I want to cut down on package size). How would i display these icons? I don't want to necessarily use gui elements if i don't have to (it might get buggy with small movements. How would i display a certain camera to render to a texture?
(Sorry about multiple questions, just fits under this idea and thought process)
You could make all your icons in a white/gray color scheme, then use GUI.color to shift them. I'm pretty sure you can use that the same way you would shift skins, but I don't have any experience using that yet.