Learning Unity 3D
2017-08-20As I mentioned in my last post, video games are why I started programming and I'd like to get back into game development. So I recently installed the Unity game engine and started going through some of the tutorials.
I started at the beginning with the Roll-a-ball tutorial. Although what you end up with after completing that tutorial may seem simple, I was pretty impressed. Having done game stuff without the benefit of an engine before, it's pretty amazing what a complete beginner can do in an hour with Unity.
I had an idea for a simple game prototype that's not too different from that tutorial. I have a pet parrot and he has a game — I use that term loosely here — he likes to play where you put his toys on top of his cage and he runs around on top of the cage and pushes the toys off onto the floor. He then stares down at the toys on the floor and demands that you pick them up for him. My idea was basically just to create this game with the player in control of the bird.
So I started by just adding a plane and a sphere as in the Roll-a-ball tutorial. The plane represented the top of the cage and the sphere represented a ball toy. Then I added a roughly bird-sized green cuboid to represent the bird (our bird is green). At first, I tried to control the cuboid the same way the ball is controlled in the tutorial. But that was just tipping it over instead of pushing it. So I switched to using a CharacterController instead of a Rigidbody and that worked well. Once I had the cuboid moving around, I just needed to be able to push the sphere. I was able to get that working with code based on the answers in this Unity Answers post.
Again, what I ended up with was very simple. But I was able to make something in two or three hours that I believe could've easily taken weeks if I were writing it completely from scratch. The main reason I think it would've taken so long from scratch is the physics. Even for simple shapes, the math for collision detection and response can be pretty complicated, depending on how correct/accurate you want to be. My hope with learning Unity is that I'll eventually be able to create something closer to a full game (that's actually fun to play), rather than the tech-demo-type things I've created in the past. And while this is still just a tech demo, the fact that it took so little time to create is a good sign. I'm just getting started with this bird game, so I hope to talk to about it more in the future.
Continuing with my Unity education, I also completed the space shooter tutorial. That one is more in-depth and leaves you with something closer to a full game at the end. It took me a couple days to complete. Again, I was impressed with how much can be accomplished so quickly. In high school, I built a game from scratch that was very similar and it took me months. Of course, I was inexperienced at the time, but it would still take me a while to do that from scratch today.
I've noticed that programmers often have a tendency to want to build everything from scratch. We like being able to understand and have complete control of all the details in our programs. And, of course, it's good to understand how things work at a fundamental level. But if you insist on doing everything yourself from scratch, you'll be severely limited in the scope of your projects. I have to remind myself of that occasionally and let myself embrace higher-level tools. And that's exactly why I'm learning Unity.
But Unity isn't the only tool I'm currently learning. One point that the Unity space shooter tutorial really drove home for me is how important it is to have artistic assets available to use. It's only because the tutorial provides those assets that you can create the game so quickly. I can imagine that creating the assets might take as long as the game itself. Because of that, I've decided that I need to learn how to create some simple assets for myself. I've started learning Blender, which I'll talk about in my next post.