Dev Blog

Hi, this is the Stranded III development blog. What you see here are actually posts from the Stranded III Dev. Blog Thread at UnrealSoftware.de. There are currently 74 dev blog entries. Click here for an overview
66

Entry 66 - 3D Inventory Items - June 11, 2017

3D Inventory Items
Why should I waste video memory and effort for 2D item icons? I have cool 3D meshes!
Unity 3D is - as the name implies - a 3D engine. An the entire UI is in fact 3D too. It just looks 2D. I can easily mix in 3D meshes! And that's what I did:
IMG:http://stuff.unrealsoftware.de/pics/s3dev/ui/inventory3d.gif


Fun stuff!
I'm using Graphics.DrawMesh (like I did for the icon preview rendering) this comes with the advantage that no game objects need to be instantiated for the 3D items in the inventory.

I use very simple code to get the right scaling for the 3D items:
1
2
3
4
Bounds bounds = mesh.bounds;
Vector3 boundsSize = bounds.size;
float maxBounds = Mathf.Max(boundsSize.x, Mathf.Max(boundsSize.y, boundsSize.z));
float scaleValue = 0.32f / maxBounds;

So I'm basically just getting the axis where the mesh bounds are the highest and then I use that for scaling. 0.32f is used because the UI has a scale of 100 units per pixel and inventory slots have a size of 32x32 pixels. 32/100 = 0.32f.

As you can see in the gif some items do not fit perfectly. That's mainly the case for items which are not "centered" in the coordinate system. The best example for this problem are the mushrooms. Their center is at their bottom, not in the middle of the mesh. I guess and hope that it isn't a huge problem to fix that. Letting these items rotate around their actual center might be a bit trickier though.

By the way regarding rotation: The way the items are rotating in the gif is just an example. The rotation in the final game will look differently. Maybe the items won't rotate at all or only a little bit. I have to find out what looks best. I also plan to make them scale up a bit when you hover them.

If you ask yourself what the first item is: It's a backpack without texture and which I accidentally exported with weird and messed up scaling.

Oh and please also note that I did not set up the materials for all these items properly yet. They all look a bit glossy and for many it really doesn't make much sense. I know!

Sorry for the long* post. Here's a potato!
IMG:http://stuff.unrealsoftware.de/pics/s3dev/models/potato_pre.jpg

> click to enlarge




*) I'm aware that the post is not that long at all. 9gag people will understand.
66

Disqus

blog comments powered by Disqus