Unity - handrolling meshes
The other day I decided I needed to set myself a goal to work on in Unity. A game project to help focus my self education.
What I settled on is a Battlezone style game. (Not a port - just the basic ideas.)
So one of the things I need is a tank to shoot at. Which means I need to create a model which Unity will then display. While I could download Blender (also free), that seems like overkill for something as simple as a Battlezone tank. What I wanted was something dead simple - an ASCII file format which Unity could use to create simple objects.
With some Googling I learned the "OBJ file" supported by Unity was just that - a simple ASCII file format. So I sketched out my tank (which is even simpler than the supertank in Battlezone), figured out the coordinates for the vertices and mapped those to faces. All nice & neat - and I even commented stuff.
And Unity refused to load it.
At first I didn't even see the error message - putting it in the scene just created an empty object. But then I happened to look at the console and saw the ImportFBX error (which confused me even more as FBX is a completely different file format).
I bashed my head against the keyboard trying to figure out what I was doing wrong. Was it because my OBJ file was too simple? (I didn't specify normals or a texture.) I selected different options to no avail. Was I missing something in the file which was causing Unity to misidentify it? I copied the sample file I used as a template and it failed too.
Then I grabbed another OBJ file off the web and that one worked. Huh? I looked at the file closely. It didn't include normals or textures either. The basic format was the same. Then I saw it - this file didn't have comments after the vertices and faces. So I removed them from mine and Unity was happy - and so was I.
5 Comments
Recommended Comments