Jumping back into gamedev with Unity

My motivation

As I’ve been getting older, I’ve found a simple trick for introspection: look at yourself a decade ago and ask that person what makes him happy. The core parts of you, the essential parts of you, probably haven’t changed much. For me it was 3 things: boardgames, video game programming, and first-person shooters. Those are the only things that would regularly get me out of my own head.

Other things, however, have changed in the last 10 years. First, for some reason I seem to have a 1/5th of the leisure time that I used to have as a kid. Second, someone now pays me to program 8 hours a day. Suddenly, the idea of spending 2 hours every night working on video games seems onerous, burdensome. It’s just not as fun when you spend every day programming stuff.

But, as I said, your core self rarely changes. Just because you don’t have the time or energy to be passionate doesn’t change what gives you joy. Growing up is kinda like being a pokemon and going through evolutions. You are still some weird, blue turtle-monster. You just have cannons coming out of your shell now. So, I’ve been working my way back to the things that make me happy.

Blastoise

Adulthood. It’s like having cannons coming out of your shell.

Since I got married, I’ve started playing a boardgame every night with my wife. It’s really been beautiful to watch. It’s great seeing a hobby you thought was lost forever, come back to life. It reminds me of the signs at the Phipps Conservatory. On some of the plants they say, “I’m not dead, I’m dormant!”.

dormant

Your passions. Not dead, just dormant.

Now that boardgaming has come back to life for me, next up is reviving game development. Of course, since it’s been 7-10 years since I’ve really been into video game programming, my analogy is more like the corpse flower than the African tree grape. Oh well.

Picking an engine

One of the things I wanted to do first was find a game engine to work with. The biggest frustration point I had working with something like pyGame was that you had to build everything from scratch. It felt like one of those popular survival games where you have a rock and some flint, and you have to build a rocket launcher. A game engine is a great way to avoid all the boilerplate and focus on what makes your game unique.

There are tons of game engines out there, but just a few popular ones that come to mind. The ones I keep hearing about are Unreal Engine, Unity and GameMaker. Of the three, I would expect GameMaker the easiest to jump into, but also the most limiting.

The biggest thing it came down to was programming language. Unreal uses C++, Unity uses C# and GameMaker uses a custom scripting language. I use C# in my day to day work, and if I can learn it as a hobby, that’s a big win.

The only other big C# based engine I know of is MonoGame, which was built on the corpse of XNA Game Studio. I’ve played around with MonoGame and it seems well made, but the asset pipeline situation is frustrating. Additionally, you still have the rock-to-rocket-launcher issue just like pyGame, but not nearly as bad.

Unity has some other things going for it as well. First off, they recently announced the free version would have feature parity with the professional version. This is absolutely amazing. And until you are making $100,000 a year you don’t have to pay for the professional license.

Additionally, Microsoft also announced a partnership with Unity. This means strong support for integration with Visual Studio. Being able to take advantage of my favorite IDE is a great feature.

My progress so far

So, I’ve been working on the very first tutorial. So far I can make a sphere roll and jump around on a small.

Animation of a ball rolling around in a box

Jumping means my game is inherently better than Stanley Parable

It’s not a lot, but I can already see a lot of the power and appeal of the tooling. Additionally, the tutorials are top notch and very easy to follow. I really expected working with 3d to be a lot more intimidating.

Overall thoughts

Even after working with Unity for less than an hour, I have a few first impressions.

It’s easy to get started

The first tutorial takes just over an hour to complete. At that point you’ve created the minimal definition of a 3d game. It would probably have taken me a week to do all of that from scratch, hand writing OpenGL calls.

It’s also got a very quick debug cycle. You code something, test it, make a tweak, test it again. It’s literally as simple as hitting play on the scene. Additionally, much of the details are accessible as GUI controls. This is especially cool when it’s your own custom scripts. All public variables on your scripts become editable. You can even drag and drop, if the variable is a game object. For example, for the camera controller we drag and drop the player object.

image

It seems really well polished

I don’t know if there is any one thing I can point to, but overall a couple of things stick out:

  • The UI seems fairly easy to navigate.
  • There are a ton of features regarding components or physics.
  • I can see right away how I could use the power of C# instead of being limited.
  • It makes adding behavior to an object super simple. Just a few lines of code and your object is controllable.

It just seems like a quality piece of software. I’ll be interested to see how it looks after 100 hours isntead of just 1.

It’s different than what I’m used to

Unity does things very differently than I have in the past. Using components over inheritance is new to me. I can see how it makes it really easy to add behavior or functionality to entities.

Another thing is there seems to be a heavy focus on encapsulation and separation of concerns. Components have functions for the event cycle: start, update, fixedUpdate, lateUpdate, onDestroy, etc. The components know only as much as they need to, and you have to work to go outside of that. I’m used to one giant loop of logic and processing behavior manually.

My way or the highway

One of the downsides of using a framework or engine is that there is usually a “right” way to do things. The downside of having guard rails is when you want to go out of them. Working with Unity, I definitely get a vibe that there is a “Unity way” of doing things. Not in any way that is a problem at first. But I immediately have a few questions in my mind:

  • How do you determine which entities get processed first in an event? Do you have any control?
  • How do you handle mass interactions between entities?
  • What if you want to use a different physics engine?
  • What if I don’t want to use scenes?
  • What if my whole game is procedurally generated?

It’ll be interesting to see if it presents a problem or not.

Final thoughts

Overall, I’m very excited to be learning Unity and see where it takes me. It’s used by tons of indies and has a lot of potential.

Why the Raspberry Pi 2 is my main computer

So this here is my primary personal computer.

pi_picture

Did you miss it? I don’t blame you. It’s the exact same size as my mouse.

pi_picture2

[Left: A multi-purpose Linux computer. Right: A logitech mouse.]

I’m using the Raspberry Pi 2 for most of my computing computing needs at home, even though I’ve got two laptops that are loads more powerful. So the question is, why would I choose the raspberry pi over a beefier Lenovo Thinkpad or HP Pavilion?

1. Because I can!

Probably the biggest reason I do it is because it feels silly. There is something just wrong about being able to run Linux on a computer I can fit into my pocket. It just shouldn’t be possible. Every time I look at the board, I think “This can’t be it.Nope, this must be a joke.”

My favorite type of poem to write is the villanelle. Largely because it’s such a pain to do. You are given a very specific set of constraints and have to work your way out. The Raspberry Pi is the same way. How much compute can you get out of a $35 computer (and $105 dollars in accessories)? It turns out a surprising amount.

2. Because I can (now)!

I tried to do this before with the regular Raspberry Pi and failed. The Model B was just below the threshold of usability.The desktop was just way too slow, and trying to use Midori to surf the web was a nightmare. On top of that, the original Model B only has 2 usb ports. So if I wanted to use keyboard, mouse and a wifi dongle, I’d have to add a usb hub.

I tried using command line only, but having lynx as your main browser is not much of an improvement. I absolutely love the command line, but I don’t want to live there. Not when I want to look up reference material or do web development.

The Pi 2 passes the threshold of usability for me. It has 4 usb ports which is one more than I need. It runs Iceweasel like a champ (except for the Azure portal Sad smile). And best of all, it has 4 cores, so the desktop can be responsive even if something else is running slow.

3. Because I surf the web too much!

It turns out that most of what I do now is in a browser. I think that’s true for a lot of people these days. That’s why you see things like the Chromebook taking off.  Once you get browsing to work, you’ve hit 80% of people’s computing needs. And as I said, Iceweasel runs very well on the Pi 2, giving me modern HTML support.

4. Because forced simplicity is good.

It’s amazing how many things you can do with a modern computer and how much crap you can install on it. I’ve definitely had the problem of being on my laptop to do Serious Things©, but instead I just surf Hacker news. With the Pi, at least I’m being intellectually honest. Either I’m surfing the web or coding something in vim. That’s it.

When I need to use iTunes, or Steam, or play around with SQL Server, I go to a different computer. As a result, my brain gets context clues about what I’m doing. If I’m on this computer I must be working on something. If I’m on my Pi I’m probably relaxing. That sense of clarity is nice.

5. Because I need to justify impulse buying.

Did you know I have 4 Raspberry Pi’s? I keep telling myself I’m going to do something with all of them but I just haven’t. There’s something sad about buying tiny little $35 dust collectors. By using the Pi as my primary computer I can tell myself that at least one of those expenses was worth it.

6. Because I want a change of pace

Finally, it’s nice to just have a change of pace. I work with the Microsoft stack all day and after a while it can get tiring. It’s nice having a completely different environment for leisure than for work. Linux on a credit card size computer is a sizable leap, for sure. This also provides me a nice way to learn Linux and diversify my skillset a bit.

Runaway Transaction Log: part 1

Last week I wrote about an idea to create labs for when things go wrong in SQL Server. They are partly inspired by the TechNet Virtual Labs, which are a great resource available for free. Another motivating factor is a desire to do something with Windows Azure. I’m new to the virtualization world and want to learn more about it. For someone like me who doesn’t have a lot of lab resources at home, it offers some exciting opportunities. Finally, I’m just plain frustrated with the fact that most DBA training involves frantically struggling when something goes wrong in production.

Today, we are going to create a SQL Server virtual machine. Later on we will misconfigure it with a runaway transaction log. This article covers just the basics. If you want to learn more, you may want to read  Getting Started with SQL Server in Windows Azure Virtual Machines

First log into your Azure account. If you don’t have one, you can create one pretty easily and you will have $200 in credits to play with the first month. Be aware that after the first month you will be paying for storage, even if your machines are turned off. Once you are logged in, go to virtual machines:

image

Then on the bottom left corner, select NEW –> Compute –> Virtual Machine –> From Gallery

image

The gallery has a lot of options available and even more if you know the cheat codes to find the hidden VM Depot. If we take a look at the SQL server category, we see images available for 2008 R2, 2012 and 2014 CTP.  This lab should work for any of those, but in this case we will be picking SQL Server 2012 Standard.

image

Once you’ve chosen your image, click on the next arrow. On the next screen you are going to pick some configuration details. I would pick the latest release date. Medium size should work for out needs regarding compute. WARNING: Be aware that Standard on a medium instance will cost you $0.73 per hour.  If you accidently leave it running all day, that can be $18 per day. I’ve done that before, so be careful.

image

Next we need to set the cloud service. You can think of this as a sort of container for the VM’s. In our case, we’ll make a new cloud service. You are going to want to pick a region close to you.

image

Finally, we are going to set the endpoints so we can talk to the machine.

image

Once you are done with all of that, it’ll take about 10 minutes to provision the machine. Go take a walk and come back.

Are you back? Okay, let’s go back to virtual machines and take a look at our machine.

image

It looks like it’s up and running.  Next, we are going to create a very small data disk for us to fill up. If you want more information, this article covers attaching a disk in more detail.

Select the machine and click attach at the very bottom. Then select attach empty disk.

image

We want to select 1 GB as this is the smallest size we are allowed.

image

Now we have everything we need to log in and start breaking the machine. Next week we’ll configure the machine to run into some transaction log issues!

An idea: SQL Server crisis labs

Many people in the SQL Server world have become DBAs by accident, myself included.  The problem with being an accidental DBA is that you usually learn things the hard way: when something is on fire. At that point, you are under intense pressure to solve everything NOW. It’s a real pain.

Of course, there are a number of great resources if you are learning SQL Server from scratch.  Here are two of them that have helped me:

These will lead you in the right direction, but the real challenge is learning how to deal with problems while under pressure. Reading about a problem isn’t the same as dealing with it first hand. What I think is really exciting is the idea of a safe environment where you can solve a problem without any risk.

Enter Azure (or any virtualization solution). Azure provides a really fun opportunity, in my mind. You can spin up a virtual machine with SQL in a matter of minutes. Then you are free to break things to your heart’s content. So why not take that a step further? Why not create labs where things are intentionally broken and your job is to fix it. Your only guides are a vague error message and your Google-Fu. Just like in real life.

So, I’m going to start a series of posts on how to create intentionally broken VM’s to train your junior DBA’s on. Next, I’ll start creating Powershell scripts to automate the creation process. Finally, we’ll take a look at consolidating those scripts to create a single SQL machine with a lot of problems that need fixed.

For the first lab, I’m going cover how to create a machine with an out of control transaction log. Please feel free to suggest any ideas or provide any comments.