Coming Back to Unity After Pause

Screen Shot 2014-10-10 at 4.46.16 PMI’ve had a few side projects going on for a while.  One was a clone of Bump n’ Jump in Unity to get a feel for Unity development.  I set it aside to work on other things, but because of developments at work I’m going to have to start playing with Unity again so I picked it back up to get back into the groove.  Today I’ve written a Breakout clone and I’ll record a few observations about Unity.  You can find the Breakout code as of this article: Breakout or checkout HEAD in case I’ve decided to do more cool things with it: Breakout HEAD

  • It’s hard for me to be so removed from performance.  For instance there is no way to inline a method.  I guess .NET and mono have it now but it hasn’t made it’s way to Unity 4.6 yet.
  • It’s difficult to layout the code conceptually.  In the Breakout clone I put most of the logic for the game into the BallController.  He is the guy that knows the most and is the controlling factor for the game but it feels weird for him to be the arbitrator of the score and game state.  I think an empty GameObject for the game who listens to the balls events would feel cleaner to me.
  • The 4.6 UI tools are very nice.  It’s easy to get UI pixel perfect on screen.
  • On that note, I had a hard time getting the coordinate space to pretend to be 640×480.  Maybe I was fighting the system a bit but 640×480 seems convenient for me to think about when making a 4:3 game.
  • MonoDevelop is horrible.  I had to turn that off, it can’t even kill and yank correctly.  I’m now using a combo of Emacs/omnisharp-mode.  Maybe I’ll make a blog post about this setup later.
  • There is some magic that has to be done to get Unity to behave well with Git, this guy on StackOverflow laid it out nicely: How to use Git for Unity?
  • Breakout has such a well define physics, it was interesting to consider if I should use Unity’s 2D physics or to roll my own.  I eventually opted for rolling my own instead of trying to hack the physics engine.  It would have been nice to be able to use the Colliders by hand without the physics but I didn’t see a nice way to do that, so I had to throw them out as well.
  • Levels in Scenes or XML?  I just have one level right now but it was somewhat tedious to lay it out by hand in the editor (especially because of the coordinate system).  But it was convenient to be able to see the results and if I had 30 different levels to able to click through them and see them would be helpful.  It seems like I haven’t found a good answer in Unity about when to use Scenes and when to use XML.

Now I’m feeling a pang to post this for the Unity Web Plugin so we can all play with it.  Hopefully I’ll get around to that to spare you the trouble of loading up Unity.

Mike Acton’s Data Oriented Design

Mike Acton, the Engine Director at Insomniac Games, had a talk from CPPCon get posted on Gamasutra yesterday.  Here are some thoughts, if you missed the video you can check it out here:

Mike Acton’s Data Oriented Design

Mike has a very interesting job.  Many developers have the luxury of accepting inferior performance for ease and speed of development.  His job is at the extreme other end of needing to geek out as much performance as possible from a machine.  So looking from his point of view provides a very different take on what we do.  Some might think his talk is extremist, but remember his job is an extreme.

The thesis of his talk is that it isn’t wrong to write code that is designed for computers instead of humans.  He warns us of overcomplicating problems by translating reality to computers while trying to maintain human understanding of reality with real-world models.  To help us look outside of our ingrained real-world model thinking he gives us an alternative model of looking at software, its just transformations on data.  Data is the focus, not code.

This doctrine isn’t necessary for each software engineer to follow, but it definitely is a helpful lens to evaluate our software.  Looking at our software as data transformations is an aide we use all the time when we write unit-tests.  Over prescribing real-world models could be a problem in certain domains too, it’s hard to know when a tool is helpful if we don’t consider the merits of the alternative.