The inventory won’t be particularly useful in the Arena, so I don’t really know why I’m doing it now. It may not an essential feature for the initial demo version of Exon, but it is an important feature for the long run — after all, you’ll find lots of equipment in your travels, not all of which you’ll want to use immediately.
So here I am, doing the inventory screen anyway because my mind did that thing where it started to fixate on the feature for no particular reason, and who am I to deny my subconscious whims?
Not Inventoried Here
For the longest time, I planned to do a proper grid inventory system, where each item would occupy a number of cells and you’d have to reorganise them to fit around each other — that is, full-on inventory Tetris. I was planning to cleave heavily towards Deus Ex, though with a finer grid that might allow you to weave awkward shapes together to squeeze everything in.
I have decided not to do this, mainly because I need to automatically generate item icons.
I’ve had a rudimentary icon generator for years now — you’ve possibly noticed the primary weapon indicator in the bottom-right of the screen shows the weapon you’re currently wielding. Way back, I swithered over whether to manually process items into screenshots or make the effort to automatically generate them at run-time; in the end, the intended profusion of materials and item types meant manual effort was never really viable. (Making 3D models of cool swords is fun, posing and screenshotting them consistently is not.)
Luckily Unity is quite happy to let you take screenshots during gameplay. When an item needs an icon, I make a clone of it, force that into the UI layer, place it off screen and use a special camera to render it alone into a texture. Handily, the camera can even be configured to take screenshots with transparent backgrounds — ideal for cut-out icons. I guess if I wanted to go all WC3 I could add some borders at this point, but straight cut-outs suit Exon much better.
Positioning the items for taking the picture also involves positioning the camera to ensure the item is framed nicely, to occupy as much of the square texture as possible. In order to do a Deus Ex-style grid, I would have needed to take everything directly side-on and then process that into a lower-resolution grid shape — but with items of wildly varying sizes, this is not necessarily an easy problem. Tiny little short swords can and will share the universe with huge blast shields (which are even bigger now I’m fully committed to sword-and-board mode). Should everyone have a 256×256 icon or would I need to vary those sizes too? Eurgh.
(Also some smaller items just look really shit side-on.)
So I figured I’d focus on getting every possible item framed to a square, and fall back to a Baldur’s Gate-style (or indeed Warcraft III-style) system where each item takes up a single inventory slot. This approach actually makes things pretty easy — Unity provides world space bounds for each mesh renderer, the values for which can be plugged into an orthographic camera (where bounds.size in the axis you’ve lined it up on maps directly to camera.orthographicSize — obviously using a perspective camera would throw this magical relationship out the window). Bounds also expand to cover rotation and scale, so bit of stylistic rotation can be applied and the final camera will still fit the calculated bounds.
Guess I’ll need to implement weight and encumbrance to make up for the lack of Tetris, though. What a shame.
The inventory screen itself is an annoying munge of logic but fundamentally there’s not all that much to it.
When you pick up an item without equipping it, it is hidden from the game world and carried around inside your mech (we’re ignoring conservation of mass here, shush). Carried items act only as icons until you drop them on the ground or equip them. Interaction is straight out of Baldur’s Gate: left-click on an item to pick it up, and click again in a slot to place it there (or on the space around the hero close-up to drop it). Right-clicking an item brings up the details pane so I can flood you with LORE (and, uh, okay, fine, relevant item stats).
With that out the way, you’ve probably noticed there are three tabs along the top of this screen — which means that quests and the journal screen are up next…