Editors Note: Pat from Crawl Space Games was kind enough to share his experience and some tips in creating his first game using Unity 3D for the iPhone. This will be a great help for those getting started with Unity 3D or trying to decide whether they should use it for iPhone development.
Coming from a background in web programming and databases, my first experience with game programming was a surprisingly pleasant one. While “Knife Toss” isn’t exactly “Call of Duty: Modern Warfare,” I was still initially concerned that I would have no idea how to even begin working on a video game. But in the end things became very intuitive and I was able to use my prior software engineering skills to adapt quickly to the environment of game development. That is not to say there wasn’t a learning curve throughout the process.
Knife Toss Game Trailer:
Understanding Game Objects
The biggest obstacle for me was getting a grasp on game objects in Unity3d. A novice game developer might find this task extremely simple. But I had never worked with 3D graphics, textures, materials, colliders, meshes or anything related to modeling or gaming. Once I was able to figure out how all of that worked, and how to wire up the code to it, things became comprehensible. It was challenging enough to make me think, but not so hard that it would take the fun out of it.
Coding With C#
Textures are what killed us. We got to the final stages of finishing the game when I discovered that we were using up huge amounts of RAM. I had never thought to check before because the game always ran fine on my device. It turns out it did not run fine on other devices, specifically the first generation iPod Touch and the original iPhone. We ended up having to redo all the texture sprites and consolidate them down to two 1028×1028 sheets. This began the most frustrating week and a half of the whole development process for me. I had to redo all of our menus, GUI elements and on screen displays by readjusting all of their coordinates. Finally we got everything back in place and as a result we cut our RAM usage by almost 20MB.
Submitting To The Store
Now that our game was optimized and working well on all compatible devices, we were ready to put on the finishing touches and begin intensive testing. When the game finally was complete, I carefully went through Apple’s process to submit to the App Store. This process is not as difficult as it seems when you first glance over their set of procedures. Our first game was finally submitted and it felt great. I still wasn’t fully satisfied though. I had read so many horror stories about the App Store submission process that in the back of my mind, I actually was expecting to be rejected the first time around. I was wrong. The game was accepted a few days later. After working through a bit of a mix-up with the contracts our game was finally for sale across the world.
Some Tips For First Time Developers
My first experience with game development was an excellent learning process. Now that our team has the first game out of the way, look for us to begin pumping out games left and right. Here is a list of tips I have for any first time game developer, specifically using Unity3d for iPhone:
- Go through the tutorials that are provided for you. I read through them, started them, but then became to impatient to finish. Had I actually finished, I would have saved a lot of time instead of having to go back and figure out how to do certain things which actually were covered very well in the tutorials.
- Plan out your game as detailed as possible before beginning. If you are working with a team, make sure this idea is stressed. What may seem like a minor change or addition to someone who didn’t program the game, may be very difficult or may require completely redoing certain aspects of the game on the programming side. This also will prevent “band-aid programming.”
- Use texture atlases and use as few sheets as possible.
- If possible, do all testing on a first generation device. If it works on that it’ll work on the faster devices.
- Use the Unity Remote. It’ll save you tons of time.
- Create a copy or a pseudo “version” of your project at least once a day. Sometimes things will get messed up and you won’t be able to figure out what you changed to cause it. Always have something to fall back to.
- Use Object Oriented Programming often. Nothing is more irritating then searching through your huge, single class file to find one of the hundreds of variables that have been accumulated.
- Use the profiler and Apple’s “Instruments” often to check your games performance and resource usage.
- Read through the documentation in Unity. Especially the optimization sections. It contains plenty of useful and sometimes absolutely necessary tips to make your game ready for sale.
- Avoid allocating memory during game play if possible.
- Use the Unity forums. For the most part everyone is very helpful and they are not rude to beginners as long as you aren’t asking questions that are readily available in the documentation. Also, the search feature is your friend.
I’d love to help out the best I can if anyone is looking for help getting started. Feel free to email me at [email protected] or just post to the Unity forum. I always reply to post if I think I can help out.
You can also check out Pat’s website Crawl Space Games where his gaming creations are featured.
The free open source Cocos2D game engine is something that is searched for and talked about alot on this site. I occassionaly receive questions about the engine, and most often I’m asked about beginner tutorials. Typically I’ll just reply saying to go through the example, and I think that’s a great way to learn how to use the engine. Many great examples are provided, and if you really want to understand the question going through the examples systematically will teach you the ins and outs of Cocos2d programming. That being said I’ve found this tutorial that does an exceptional job of showing you the absolute basics.
In the tutorial Ray goes through the creation of a simple 2D shooter. Specifically, downloading and installing Cocos2D, using the Cocos2D application template, adding sprites, moving targets, shooting projectiles, collision detection, and other game creation essentials in a step-by-step fashion.
[source Ray Wenderlich]
I’ve posted many iPhone game development resources on this website, and I can see that many of the searches on this website are iPhone game development related so I have decided to create this post which is basically a table of contents containing my other iPhone game development posts, along with some new iPhone game development resources that I have not mentioned before.
iPhone Game Engines
When most look to develop a game on the iPhone typically alot of time can be saved by using an already existing game engine. Some of these engines use Wysiwig editors and their own scripting languages while others provide a collection of functions to us in your code.
Game Engine Resources
Unity 3D and Cocos2D are two widely used game engines, I highly suggest looking into these two engines if you are getting started with iPhone game development.
You may want to use Core Animation to program your game, often this is the easiest way to program simple 2D games with low performance requirements as you can lay out elements in interface builder and the functions are very easy to understand if you’ve done other iPhone Objective-C Programming.
Core Animation Resources
OpenGL ES is the rendering API used on the iPhone. If you are looking for maximum performance and don’t want to purchase or use an already existing iPhone game engine you will need to use OpenGL ES.
Free Game Graphics
Something I see commonly asked is where to get graphics, well the fact of the matter is you will typically have to pay an artist to create them, or create them yourself, but there are some free graphics available. The games you can make with these are somewhat limited, but they can be good for prototyping before finding an artist to assist you with iPhone game development.
The iPhone uses OpenGL AL, as mentioned above Cocos2D now includes a sound engine, but if you’re programming from scratch here’s a basic engine for you to learn from.
Finch Simple OpenAL Sound Engine
Free Game Audio
Here’s some links to some free audio as with graphics you’ll typically have to find someone to custom create the sound you want or create it yourself to get things right.
iPhone Game Development Community
You may want to check out iDevGames if you’re looking for a forum for iPhone game development. It is fairly active.
iPhone Game Development Tutorials
The guys at 71 squared have put in a tremendous amount of work into creating some iPhone game development tutorials with video, be sure to check them out.
That’s it for my iPhone game development resources compendium, as always if you know of any other great resources feel free to post them in the comments, and I will likely update this post in the future so look for them to be added later on.
I’ve made quite a few posts about OpenGL ES, and the available game engines on the iPhone, and I’d like to iterate that you do not need to use OpenGL ES or any game engine. Core Animation can be used for iPhone game development, and if you’re used to Objective-C/Cocoa it may be the easiest route.
There are some caveats to using Core Animation, for one, you can get better performance from using raw OpenGL ES, and it can be somewhat tedious to use in instances where you may want to micromanage the animation of a graphical object. Also, while there are 3D transformations available Core Animation is designed for 2D graphics. All this being said, Core Animation is great for games such as card games, and board games. A huge advantage of Core Animation is that you can lay out your components using interface builder which can be a real time saver, as all the graphical components are inherited from UIView.
You wil want to check out the manual on Apple’s official Core Animation Programming Guide here:
Core Animation Programming Guide
While much of that guide is for Mac, you can also check out the Core Animation Cookbook:
Core Animation Cookbook
As far as code samples go the best example I’ve seen is the fantastic Geek Game Board, and an iPhone compatible version with some updates beyond the Mac version available at the Apple site is here:
and for those who have trouble downloading the source can find it here:
Geek Game Board From Bit Bucket
I was able to get this example compiling to iPhone OS 3.0 straight out.
What makes the GeekGameBoard example so good is that it includes board games, and card games (specifically Go, TicTacToe, Hex, and Klondike) that you can use as a framework which includes cards, boards, and pieces that you can use in iPhone game development. This should get you off to a very fast start.