I Made a Thing

By Shamus Posted Tuesday Jul 17, 2018

Filed under: Programming 41 comments

People have been saying things like, “Hey Shamus, what happened to those programming posts you were doing. Weren’t you in the middle of a project? Weren’t you wrapping up a project? What’s going on?”

Here’s the thing:

A friend of mine has been working on a Minecraft-style cube world where the front end is built on C++ and the backend runs on user-editable LUA scripts. Early in the project I was talking about some of the techniques I’d used to generate blockworld caves. Then I figured it was sort of lame to just describe the structures I was talking about, and it would make so much more sense to show him. And hey, why not kill two birds with one stone? I’ll make a blockworld to demo the caves, and I could turn the process into blog posts.

Ooooh. Spooky! Sorta.
Ooooh. Spooky! Sorta.

But then I just kept adding to it. I finally got over the initial hurdle of working with Unity and reached the point where I could write code without needing to stop after three minutes of coding to do thirty minutes of forum-diving to answer simple questions. It was fun, so I kept going.

“I’ll turn this into blog posts when I’m done,” I lied to myself.

By the end, I’d made a block world, several layers of underground caves, a primitive building “interface”, a day/night cycle, a lunar cycle, the surface world with different biomes, and a system for importing Blender models. Oh, and I’d made a few blender models.

But then I found out I’d lost all my GTA footage and needed to re-capture it. And then I started writing about Andromeda. And when that’s done I have a novel and a videogame waiting for me. And when all of that is over we’ll be near the end of 2018 and I won’t have any memory of this project.

It's JUST LIKE MINECRAFT, except without the mods, interface, multiplayer, or gameplay.
It's JUST LIKE MINECRAFT, except without the mods, interface, multiplayer, or gameplay.

So in an effort to make it count for something, here it is. You can download the non-game here.

The controls:

F1 - Help screen
F2 - Spectator / flycam
F3 - Show a bunch of dev info.
F5 - Reset position.
~ - Open the useless console window.
I - Invert mouse.
Mousewheel - Change the block in your hand.
Left Mouse - Place block.
Right Mouse - Destroy block.
Middle Mouse - Select block / clear hands.
Space - Jump.
F12 - Exit.
[ and ] - Forward / backward time lapse for daylight + lunar cycle.

I made those trees in Blender. Honestly, that was more difficult and confusing than writing the code that drives the game.
I made those trees in Blender. Honestly, that was more difficult and confusing than writing the code that drives the game.

Making this useless demo is probably not the best way I could have spent those hours, but what can you do?

I will say Unity is pretty amazing once you absorb enough of it to get work done. I don’t know if I’d actually use it for something resource-intensive like a full-blown blockworld, but for any project where you’re not pushing against challenges with memory usage and draw distance, this is my now my go-to tool.

Also, the default Unity workflow is not mod-friendly. When you’re working on the project, you’ve got all your files in a nice clear directory structure where you can modify individual bits of code, models, textures, sounds, and whatever else you’ve got. Then when you’re ready to deployFancy talk for “package up so non-developers can run it”. it stuffs all those files into obfuscated proprietary files. Like, I don’t even know where my texture data IS in this deployed version.

Yes, the grass waves in the breeze. No, it doesn't look particularly good.
Yes, the grass waves in the breeze. No, it doesn't look particularly good.

If I wanted to make it so users could modify game assets, I’d have to implement a lot of resource-loading stuff by hand. That’s annoying. The files are RIGHT THERE in the development version, but I can’t get Unity to NOT hide them.

Ah well. Hope it gives you two or three minutes of amusement.

 

Footnotes:

[1] Fancy talk for “package up so non-developers can run it”.



From The Archives:
 

41 thoughts on “I Made a Thing

  1. methermeneus says:

    I mean, if you’re that concerned about figuring out where Unity puts everything in the release version, there’s probably documenta- oh, right, Unity documentation…

    1. derjungerludendorff says:

      Don’t worry, i’m sure there is a forum post about that somewhere which vaguely alludes to a solution.

      1. The Nick says:

        There’s certainly a bunch of people who know that this particular desire to open up the files for viewing is dumb and will berate you for it while saying they know how to do it but asking WHY you’d want to do so.

  2. Da Mage says:

    Those trees certainly are ….. something …. at least the pine trees look pretty good?

    1. BenD says:

      I like them! They look like some palms.

  3. Jonathan MacAlpine says:

    You can put files in the “StreamingAssets” folder directly inside Assets and they’ll be copied as-is to the user’s installation.

  4. Daemian Lucifer says:

    Sooo….while writing about an ongoing project you were slowly progressing with,you finished a different project in a cutscene.

    1. Lino says:

      Quick! Call 911: the Mass Effect 3 writer has hijacked Shamus’ blog!

  5. Olivier FAURE says:

    Oh wow, you make a block-based environment generator! There’s only, like, 2389 of them *at most* already. You truly are a pioneer :P

    Snark aside, it’s a little frustrating to see 2 billion minecraft-like games on the market, where the world is made of cubes, you appear in a forest-like environment, and you have to cut wood and mine minerals to survive. I’m talking about actual products sold for money, not hobby project like yours.

    I really wish there were more games using Minecraft’s blocky aesthetic and super-user-friendly building system, and used them for completely different genres. Sim City games, platform games, multiplayer racers, etc.

    1. Daemian Lucifer says:

      Minecraft has replaced tetris as the goto program that everyone makes when they are making their first game.Because its easy to test and see if its working as intended.Well ok,not the FULL minecraft,but the gist of it,the blocks,various biomes,trees,etc.

    2. Gordon D Wrigley says:

      I have a logic gate simulation with a Minecraft like interface. It’s on my todo list to build a whole computer in there as sort of combination educational and art piece. I know you can logic gate in Minecraft but it’s a bit akin to programming in Brainf**k, more to prove it can be done than to demonstrate logic gate stuff. Where as this is built with a focus on the construction, visualization and evaluation of the logic gates.

    3. Gordon D Wrigley says:

      Another thing on my todo list is to make an inside an asteroid type Minecraft thing with zero gravity and using a different tessellation than cubes, probably a rhombic dodecahedron as it resists the players desire to assign regualr 3d axis to it.

    4. Shamus says:

      “You truly are a pioneer ”

      Good thing I wasn’t trying to pioneer anything, then. I mean, the reasoning for making the program is right there in the post. Would you have rolled your eyes at me if I made heightmap terrain because there’s a million games based on heightmap terrain?

      Sometimes I program a thing for reasons other than making a commercial product.

      1. Michael Godfrey says:

        I think it was meant in a much more jovial tone than you seem to have imagined

        As for projects, it was actually your series on Project Frontier that first introduced me to this site. I loved that and I am still impressed when I go back to re-read it. After that I saw your video about Fuel and then I was hooked

        1. methermeneus says:

          I think that the fact that sarcasm never quite works the way you mean it to in print combined with humor not quite working the way you think it does in other languages (the post looks like the writer is not a native English speaker) to make this sound more offensive than it really is. However, I did need to read it through to work out what I think was meant, and I have a fair amount of experience in working out what non-native speakers were trying to say, so I’m certainly not going to blame Shamus for coming to the same conclusion I initially did.

          Oliver Faure, take this as a lesson in attempting cross-linguistic humor more sophisticated than fart jokes. Believe me, I’ve failed miserably at it myself. As my German teacher said, “The two ways you know you’ve mastered a language are, you use prepositions correctly, and you get the jokes.” (For reference, when I try to speak to German people, they all say we should switch to English, so I’m pretty sure I’m worse at that than you are at English.)

  6. Paul Spooner says:

    So cool!
    What is your import pipeline from Blender?

    1. Shamus says:

      “What is your import pipeline from Blender?”

      Save as .blend. Done.

      HOWEVER!

      Unity is a Y-up environment and Blender is Z-up. Rather than handling this the smart way, Unity simply reads the .blend file, and then silently applies two rotations to put the model rightside-up in your game. This means if you ever reset the object’s matrix to identity, it will end up laying sideways instead of back in the default position as you intended.

      So I ended up writing my own model importer. It takes the imported model, does the appropriate transform, and then saves it in a raw binary format.

      1. Paul Spooner says:

        Excellent! Could you make a TheDeeps sourceforge project? I’d love to contribute models to this.

        1. toadicus says:

          I’d like to echo the request for source with the caveat that it be uploaded almost anywhere except sourceforge. Github would be great so we can do forks and pull requests, or elsewhere if you don’t git Git.

      2. Paul Spooner says:

        Found the Blender files in “TheDeeps\Assets\Resources\ImportModels” but changing them doesn’t change the in-game models. Is there an importer I have to run or something?

        1. Karma The Alligator says:

          Aren’t the in-game models prefabs? If so you’d need to update the prefabs

        2. Shamus says:

          I had to look this up. There’s a script that will load all .blend files and update the binary models. Sadly, you can ONLY activate this script from within the Unity editor. This wasn’t a deliberate attempt to hinder the user, it’s just that Unity makes it really easy to create interface buttons to run scripts. I do the same thing with the texture atlas: Press a button, and the program auto-builds it.

          If I’d known I was going to dump this thing in public, I would have added console commands to access these scripts.

      3. Piflik says:

        I usually have the mesh as a child of the actual object I am manipulating. Then I can rotate/move/scale it however I want and don’t need to muck around with different coordinate systems.

        (from 3ds max to Unity is even worse: 3ds max uses the correct coordinate system (right-handed, z-up), while Unity’s is wrong (left-handed, y-up))

      4. Mr. Wolf says:

        One more for the list of things that need an industry standard.

  7. Paul Spooner says:

    Bug report:
    *Start the game, hold down ‘[‘, the sun never rises. Has something to do with GameTime being negative.
    *When viewing the lava floor in TheDeeps biome, face-finding will occasionally let me place blocks on hidden faces, which erases existing lava blocks.
    *Reset position does not reset velocity. Combined with the very small ground-bounce and no terminal velocity, this launches the player into the air after resetting from falling out the bottom of the world.
    *Self-entombing allows the player to fall through the ground.
    *One of the tree blocks just shows up as a block instead of instantiating a tree.

    1. Paul Spooner says:

      Ok, found the “blocks.xml” file. The “tree block” I refer to above is actually the “Junk” block. Replaced it with the “Firepot” block, which works fine, but doesn’t emit any light!

    2. Zak McKracken says:

      I was able to get the sun to rise using the ” ´ ” key (that’s the diacritical thingy, and I don’t even know where that would be on an EN-US keyboard). My hunch is that the code doesn’t deal with keyboard layouts very well.

      Things I noticed: When flying very high (I had to plant a tree on that spire), then flying relatively far:
      1: you sometimes need to get pretty close to the edge of visible space before the next bit pops in. That actually made me fall down the rift all the way into lava at first — because I was seeing stars down there.
      2: While flying high and looking down on the plain, with the sun behind me, I find a veeery large shadow-ish thing flickering into existence below, then vanishing and so on.

  8. bruh says:

    uhhhhh

    is it just me or is the “non-game” not nice with my notebook control
    i mean, my notebook already has all these F1/F2/F3/F-blahblahblah keys that are somehow programmed to do pre-set tasks for anything, and pressing Fn* for me doesn’t work very well either

    * Fn was supposed to be a key to aid in pressing F# keys without affecting anything regarding your computer – laptops/notebooks have a lot of this stuff

    1. Daemian Lucifer says:

      There should be an option in bios to switch the default thing of the function keys.But depending on the manufacturer,it may be hidden somewhere else.

      1. bruh says:

        :thinking:

  9. Paul Spooner says:

    Found that there are duplicate resources in the zip. Through the process of elimination I managed to figure out that the “Data” and “Sounds” folders in “TheDeeps\Deploy_Data\Resources” are unneccesary, and the “Models” folder in “TheDeeps\Assets\Resources” is unneccesary. To my frustration, “ImportModels” exists in both locations, but isn’t accessed when the program runs. Can we get a copy of your blender-to-binary converter?
    Here’s my slimmed down version of the game (42MB instead of 74MB). Seems to run just as well as the original.
    http://peripheralarbor.com/TheDeeps.zip

  10. Stu Friedberg says:

    The simplicity of the Unity deployment “thing” can be annoying for end-users, too.

    I’ve more than one game on Steam where the devs can find no alternative to pushing the entire multi-gigabyte deployment package whenever they patch one line of code or correct one sprite animation, typically along with a release note something like “We’re really sorry about this, but our game engine forces us to release as one giant blob.”

    Obviously, the problem is solvable, but not at an investment of time and resources the developers find worthwhile. In the meantime, I have to check Steam downloads everything I log in to the service, to make sure I’m not going to be clobbered by another unexpected 2.25 to 3.8 gigabyte download.

    I’d also add that some 100-300 megabyte games provide distinctly better gameplay than some of the games 20 times as large in digital form.

    1. RichardW says:

      From what I’ve gathered talking to programmers on the game I’m involved with, this is more a thing that’s being pushed from Steam’s side. They basically *make you* package everything as a single object, both for security reasons and to work with their “SteamPipe” delivery service (which doesn’t seem to quite work as advertised).

  11. Piflik says:

    I have written some import code for work, which we then can use to import stuff from ‘open’ folders and use them in game. Would be nice if Unity games were more mod friendly, though.

    Interestingly, the code itself is quite accessible, since it is managed C# code and you can just put the Assembly-CSharp.dll into a decompiler, like ILSpy or dotPeek, and you have nearly exactly what you have written innitially. You can even change the IL and don’t even need to recompile (if you know what you’re doing).

  12. Zak McKracken says:

    Waitwaitwait! You figured things out in Blender and didn’t even post about it?

    (also: I can see the blender files and all your XML stuff alright in Deploy_Data\Resources\ImportModels … are those linked to the game, or would I have to recompile/deploy to have any updates in them reflected in the game?

    1. Daemian Lucifer says:

      You figured things out in Blender and didn’t even post about it?

      “Never mind,I found the solution”?

  13. Dork Angel says:

    Ooh, did I see mention of a novel? Really enjoyed The Witch Watch, any hints as to what the new one will be about?

    1. Joe says:

      He mentioned on the podcast that the genre is cyberpunk.

  14. This is a fun little toy game. It would be better if it didn’t start in the middle of the night where everything was dark blue. Also, I get flickering lighting during sunrise. The add/remove was working for a while, then the red outlines of the trees started going off the side of the screen as if it was placed horizontally. I had fun tunneling through the ground until I fell out the bottom of the world. Thanks for sharing!

  15. Philadelphus says:

    Having modeled palm trees in Blender myself, those look pretty good!

  16. RCN says:

    Two things:

    1. What are your thoughts on LUA, if you have any.

    2. Why don’t you ever make animated GIFs? Often you post a screenshot commenting about how the scene is animated (either criticizing it or praising it). Why don’t you just cut the middleman and instead make a GIF when you want to show a short animation loop?

Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun. Your email address will not be published. Required fields are marked*

You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>

You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?

You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.

You can make links like this:
I'm reading about <a href="http://en.wikipedia.org/wiki/Darth_Vader">Darth Vader</a> on Wikipedia!

You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>

Leave a Reply to Olivier FAURE Cancel reply

Your email address will not be published.