Monday, 21 February 2011
The joys of iAds
Or we thought so anyway, the keen edge of the learning curve struck me again as I realised that none of our ads were displaying. The reason for this was of course that I hadn't added support for them in our Unity project. Naively I thought that Apple would handle all the displaying of ads and effectively just overlay them onto our game, this is not the case.
I quickly went online and tried to see how to code them into a Unity project. I couldn't really find any clear explanations but I did find a link to a company's site which sold plugins for Unity, one of those plugins was for iAd support. I weighed up the cost of buying the plugin vs my time in learning how to do it. The plugin won hands down so we bought it, installed it and now our iAds are working perfectly. I highly recommend it, the company is Prime31.
We've submitted the new version of Viral Lite and are as ever, waiting on Apple :)
In the meantime, check out the current version of Viral Lite on the app store ->
http://itunes.apple.com/gb/app/viral-lite/id418329387?mt=8
In other news, we've submitted our next game to Apple. Its called Bloove and there will be more details coming soon on here when it gets approved!
Thursday, 20 January 2011
Lessons Learned
This discussion is specifically aimed at people developing for iOS with Unity.
The first item I want to bring up is textures, the only textures required in our game were GUI textures so with that in mind we created them exactly to size and imported them as GUI in Unity. The problem with this was that even though they were switched to 16 bit, they were taking up a massive amount of memory on the iPhone. This was made even worse by the fact that we designed the GUI for the 4th gen devices, so the full screen textures were 960x640, and we had a lot of full screen textures.
The solution to this problem was to simply reuse a couple of the full screen textures for backgrounds and then convert the overlying textures into powers of two so they could benefit from PVRTC compression. We were able to reduce our total texture size from around 50mb to 12mb, a much more acceptable number.
The second major issue we had was with meshes, luckily we managed to catch this quite early on in the development process so it turned out to not be such a major problem. The problem we had was that we had no idea what the constraints of the iPhone hardware was in terms of polygon processing, this information is actually available in the Unity help files but for some reason I hadn't been able to find it. To cut a long story short, Olly went a bit wild on the poly count and we ended up with around 70-80k polys on screen at any one time. This turned out to be about 70k more than was recommended so with some hasty remodelling we have a very safe poly count of around 3-4k on screen at any one time, this falls well within the recommended 10k. Once again this is a perfect example of where some prior research would have been really beneficial, as it is also clearly written in the Unity help!
Another issue we had to contend with was the resolution difference between the 4th gen devices and the older devices. The resolution of the new devices is 960x640 and as I mentioned earlier, we designed all our textures with this in mind. Fairly obviously this meant that I had to design the GUI elements to dynamically change based on the resolution, well I say fairly obviously, it clearly wasn't to me when I started. I decided initially to have two functions, one called DisplayHighResUI() and the other DisplayLowResUI(), I worked on this for a while before I realised that instead of declaring ExampleElement = 100; in the high res UI and ExampleElement = 50; in the low res UI; I could just work out the position based on the resolution. So in the previous example, ExampleElement = 100; could actually be ExampleElement = Screen.width * (100/960), or more simply just Screen.width * 0.1042.
This should have been obvious to me but it just shows how a lack of forethought can cause you to rush and then spend time repairing problems.
There were other issues we had involving game balance, particularly the time the game took to complete and the speed which the user had to react to events. These were quite specific problems though so I won't go into them here.
From my experience with developing our first game, I've compiled a top ten tips list for developing a game for iOS with unity:
- Plan - try and think of every problem you're going to encounter, you won't get them all but it will certainly help.
- Watch the size and use of your textures - try and get as many compressed to PVRTC as you can.
- Don't use too many polys in your models - 10k max on screen at any one time.
- Compress your sounds - I compressed our backing track from 1.4mb to 800kb with no noticeable loss of quality.
- Be object oriented - don't have enormous long classes, split them into smaller self contained classes.
- Be careful with OnGUI() - this function can get called multiple times per frame, so put as few calculations in here as possible. One bad example of this is updating a scrolling GUI element in here, it'll move faster and get called more often than necessary.
- Don't put everything in one class - I had a good example of this, I had a game class where the game logic was updated in Update() and the GUI was drawn in OnGUI(). This wasn't a good idea because the script file was huge, the update function also became extremely confusing as it was updating elements for both the game and the GUI. I solved this by creating a new class for the GUI and moved all the UI functions over to it leaving the game logic class much tidier.
- Pick a language at the start - I decided to go with javascript as most of the help examples I could find online were in java. Coming from a C++ background this was a bad choice and I wished halfway through that I'd gone with C#. My advice is go with what you know best.
- Watch javascript's dynamic casting - if you choose to use javascript, watch out for this one. iOS doesn't support it, so all your variables have to be statically typed: i.e. var x = 10; will work normally but on iOS you are required to put var x : int = 10; This nearly caught me out when passing variables in functions, the function definition must also include a type: function PassStuff( valueToPass ); won't work, you need: function PassStuff( valueToPass : type );
- Use the unity help - it's an invaluable tool and is extremely useful so don't neglect it.
Thursday, 16 December 2010
We live………..AGAIN!!!
Me cheesily sat on our first day of work. Yes that is a bottle of ketchup behind me.
I’ve now relocated to West Yorkshire, to Alex’s hometown. I’ve actually moved in next door to him and his girlfriend. My living room is basically our office with a sofa in, and it’s here that we spend our days, 10-6 Monday to Friday, toiling away.

Alex hard at work in the office
There’s so much involved in something like this this it’s unreal. We have to deal with both making the games and the nuts and bolts of making ourselves into a legitimate business. Add to that all the different stuff involved in moving house and its no wonder that sleep is a distant memory to me.
Only kidding, I’m loving every minute of it. Being creative lead in my own company gives me more freedom and flexibility than I could imagine. It’s a big responsibility, as Alex’s job necessitates that he’s told what to do by me, even though we have an equal ownership of the business. The guy’s a coding god, but ask him to make a creative decision and you’d have more luck asking a dog with a bucket on its head.
Our first game is in early alpha now, we have it in engine and are currently tweaking it to perfection before we enter the beta stage where we’ll begin playtesting. More on the game itself in an upcoming post.
We’ve used Unity to create the game, an excellent engine that we’ve found really easy to use. It has fantastic support in the shape of Unity Script Reference, its online resource centre, and we will be using it for most if not all of our upcoming projects. I am interested in switching to UDK now that Epic are integrating native iOS compatibility, but the pricing structure is not as appealing as using Unity.
Now that we are set up and with a somewhat reliable internet connection, I’m intending to fulfil my aim of providing at least weekly updates to the blog…….promise!
Merry Christmas Everybody!
Olly