World Generation Progress Bar


I finally got around to putting world generation in a background thread so I can use the main thread to show a loading progress bar. This was a little tricky since you can only interact with Unity on the main thread, so for things like combining meshes or spawning objects I added a main thread task queue, which will execute tasks for up to about 30 milliseconds each tick. That queue is pumped during a regular Unity Update call, so in order to get those tasks to run as quickly as possible I disabled VSync while the level is loading.

I haven’t found a good way to profile the background threads—Unity’s profiler only looks at the main thread and VS can’t profile Unity’s instance of Mono. I already have to monitor world generation progress in order to report back to the main thread so it can increment the progress bar, and I get some timing reporting out of that, but nothing granular. So optimizing this has been guess and check, trial and error. Like, comment out a line and see how much faster that makes it, to measure that line’s impact.

I’m definitely getting some ideas here about how I would structure an engine if I wrote one from scratch, in order to make procedural world generation faster. The main thing I think would be to have object types that are specialized instead of general purpose, so that it’s not super expensive to create an object. Making engine types threadsafe, or at least lockable, would be a huge win too.

Showed the Game at GE2

This weekend I brought the game to GE2 in Seattle. I had a great time showing the game to people and hanging out with the other indie devs that were there, showing awesome games like Lords of New York, Museum of Simulation Technology, Delver, Inversus, and more. Thanks a ton to Seattle Indies for making it happen!

I published a new build of the game last week before the show which is available at Changes since the last build include:

  • Many small polish tweaks and bug fixes
  • Cutting down things like bushes and pots is now driven by physics collisions with the player’s weapon.
  • Added enemies: Wizards, juggernaut, plant.
  • Added weapons: dagger, cardboard tube.
  • Added lava bubble particle effects.
  • Made packages in the store destroyable.
  • Chests will no longer give you a weapon or shield that you’re already holding.
  • Cars and fire hydrants will react when hit by a weapon.
  • Added colored pots which drop items when you break them.
  • Better distribution of enemies and item drops so there’s more of a progression ramp up over the course of the level.
  • Updated music.
  • Switched attack and grenade buttons (attack is now X, grenade is RT).