Unity

Kongregate Challenge Update 1

Posted on by Quick Fingers in Surrender, Unity | 2 Comments

Now for something completely different. Anyone remember the old 3DO / PC game called “Return Fire”.
Well I’m attempting a modern remake, in a very short space of time

Kongregate are holding a Unity3D development competition. (Information here) Simply make a Unity3D web game for their site and the best entry will get $10,000. So I’m going to try and create something from scratch, within the crazy short time frame.

So far so good, I pulled an all nighter and came up with a short video of my progress so far. I have helicopter and jeep physics, just 2 other vehicles to do. Also got some basic AI for the turrets and basic teams (Doors only open to correct players base, turrets only shoot at enemy).
The future TODO looks pretty long at the moment, but the next stages are to finish the vehicles. There’s 2 more to go, the rocket launcher and the tank. Serialize level data and create a really quick level editor to create many scenarios. Then …. well stay tuned, some exciting things are planned!
Anyway here’s the video don’t forget you can watch it in HD if you goto the Vimeo site here.

Guns, lots of guns

Posted on by Quick Fingers in iPad, Unity | 1 Comment

I’ve has a long list of weapons for this game ever since the first GDD really, combat s always going to be a main feature of the core. Lately i finally got round to building some of them. If you have been following me for a while and have seen some of my previous videos you may recognise some of the weapons here but there are some new ones you won’t of seen aswell, including the black hole generator – an alien weapon that creates a temporary black hole sucking in and destroying any enemies near to it. Also a Terran made nuke launcher that will destroy most enemies in range with one shot :)

I had a few more weapon ideas written down but some might not make it into the final cut. Such is the way with developing on your own, you just want to keep adding and adding but inevitably something will eventually have to give, else the project would never ever get finished!

The Core Goes Multi Platform

Posted on by Quick Fingers in iPad, Unity | 3 Comments

I was in two minds whether or not to post this… on one hand, I want to inform people that I am indeed planning to make The Core as a PC/Mac downloadable game after the initial iPad release, and was excited to show some footage of a potential battle scene with cool explosions and all. On the other hand I didn’t want to put this out there and everyone expect all these cool explosions on the iPad version. As unfortunately that wont happen. Don’t get me wrong all the other stuff here will look like this :) Just none of the Detonator powered explosions.
Here’s the video!

The Core Planet Preview

Posted on by Quick Fingers in iPad, The Core, Unity | 1 Comment

Now for something interesting :) Showing in the video below is The Core’s planet surface mode. In this you control a little hologram drone and you can search for payloads on the planet.

Some technical limitations of the iPad mean that I had to develop some interesting techniques to get a terrain. Unity has a terrain engine but it is not supported for iOS devices so I had to roll my own.

This one works using simple planes with 10×10 vertices per plane. It arranges them in a grid and modifies the y position of each vertex based on a perlin noise generated height field. This way it’s very easy to do grid based culling to only render tiles that you need on screen. On top of that no lighting is used on the terrain, instead I use vertex colors to simulate shadows and highlights amongst the terrain.

I used a very basic ambient occlusion type calculation to generate the vertex colors based on the heights of the 4 surrounding vertices. It produces smooth gradients which generally look quite natural. As you can see from the video it adds some much needed variance to the texture and the result is fine for the iPad :)

All in all I’m happy with the performance and am getting ~25 fps throughout this part of the game.

Happy viewing!

Optimizing Unity Games for the iPad

Posted on by Quick Fingers in iPad, The Core, Unity | 2 Comments

As some will know I started developing the core before the iPad was available to buy. This meant a lot of guesswork in terms of rendering performance, draw calls, vertex count and all the other fun stuff you have to think about from time to time.

This weekend just past I spent a good amount of time doing optimisation to get the core to run nice enough to make it playable.
The map screen is very light with just the star sprites and the ship taking basically no vram, and the background being the biggest memory hog here theres also no light sources and nothing really moves. So I’m getting a solid 60fps in the map screen.

Alpha Test Not Advisable
Coming into a system view with planets is a different story: originally I was getting around 15 fps on the sol system (Sol is the heaviest a system can really be with 9 planets and asteroids). The sun for each system is a particle system and a point light.

In the first system view I had clouds of very light dust sweeping through the background crossing each other.

It seems alpha test is very pricey so any layered transparency means big performance hits so unfortunately they all had to go, but I immediately gained about 5fps.

Next the planet orbit lines. These were originally drawn with line renders, one for each line. The only problem with that was line renderers don’t batch, So even though they all share a material, if there’s 9 planets that’s 9 extra draw calls, just for little lines.
Line Render Alternative
So instead of line renderers, I just built custom meshes in runtime for the lines, that way batching works and i save 8 draw calls. The intensity of the sun was something worth changing, originally it was 50 particles which gave the sun some life as you can see the shape moving and flaring away.

However I reduced the particle number to 12 and made the particles bigger which seemed to have a positive effect on the frame rate and still looks good, the sun kept its
shape a little more too it just has slightly less movement, which is fine.

Lastly it seems the ipad fill rate isn’t so hot, so having large areas of the screen changing frequently hurts. Simply zooming out with the camera slightly making all objects appear smaller had a very positive effect on the frame rate.


Now the system view is running at around 30fps I feel confident it’ll be playable. The only problem I can see is because the map view is so smooth, maxed out at 60 fps, you notice the drop to 30 when you enter the system view. Perhaps I should cap the framerate to 30 to ensure the game is consistent throughout. It just seem a shame because it looks really slick at 60!

So to summarise:
The key thjngs to remember on the iPad are low fill rate and alpha test causes strain. For those just interested in the numbers, the draw calls in system view are 33-45 with optimisations and 48-58 without. The triangle count didn’t change as i didn’t remove any meshes, so the triangles are 15,000, which means I don’t think polygon count is going to be an issue with most games on the iPad. Your more likely to hit a speed bump from fill rate before you need to redo your models.

Remember the iPhone? Well the iPad 3GS has the same GPU. But it has 5 times the pixels to draw. So by that nature things on the iPad cant really be expected to look “better” than they do on their smaller sibling, just bigger (which could be construed as better). I do think that having a nice big multi touch display that’s the most responsive on the market definitely makes the little niggles worth putting up with and remains a tremendously fun device to develop for.

New Project : Island Strike

Posted on by Quick Fingers in Island Strike, Unity | 2 Comments

Firstly, development of The Core is going well, so anyone following that project don’t worry some big developments have been made since my last update and I’ll post about those another time. For the last week I’ve been playing around with an experimental idea; to remake one of my favourite old games from the Amiga days “Wings of Fury”. And… its going well!

It’s just a fun project at the moment to keep me entertained on un-motivated days during development of The Core. But I’m really happy with how its feeling so far so maybe I’ll release it as an indie title sometime. As I’m using way too many effects, shaders, vertices and the game tops out at about 5-600 draw calls, there’s really no way this thing is getting an iPad / iPhone version at any point but still, Mac/PC executable and web player options are definitely something I’ll think about in the future.

For those of you that know your unity… the game is very light on the physics, only really using physx for triggers and queries for when the bombs hit stuff. This is to get a more arcadey feeling throughout that has a more similar style to the original. I was excited to get the Detonator explosion system add on in place and was a joy to use, and the results even with the presets are awesome. Check the videos for a good look

For kicks, here is a comparison picture of the original and awesome title against my early build.

And now time for the video . Enjoy!

Map Screen GUI Screenshots!

Posted on by Quick Fingers in The Core, Unity | Leave a comment

Finally here is a few screenshots to peruse at your leisure. This uses no OnGUI calls as I hear they are pretty performance intensive and so for iDevices its a good idea to use other solutions. There’s a few out there and I went with GUISpriteUI. However I will discuss the ins and outs of the different GUI systems available for unity in another post.

For now just enjoy these screenshots to see what kind of GUI I decided to make :

GUIText Line Breaks

Posted on by Quick Fingers in Unity | 1 Comment

If you use GUIText for your text display in unity you may have noticed there is no wrapping. Basically it doesn’t act like a text area, where you can specify a width and it’ll wrap the text, it just runs across to infinity.


So here’s a very rudimentary fix I came up with for my UI in The Core. It doesn’t take into account for full text metrics and different sized characters so its definitely “quick and dirty”. But it works and will be graceful if you have your own \n’s in your text input.

public string LineBreaks(string message, int charsPerLine) {
        string msg = message;
        bool finished = false;
        int index = charsPerLine;
        int lineStart = 0;
        while (!finished) {
            if (msg[index] == ' ') {
                int newLineIndex = msg.Substring(lineStart, charsPerLine).IndexOf("\n");
                if (newLineIndex != -1) {
                    lineStart += newLineIndex + 2;
                    index = lineStart + charsPerLine;
                } else {
                    lineStart = index + 2;
                    msg = msg.Remove(index, 1);
                    msg = msg.Insert(index, "\n");
                    index = lineStart + charsPerLine;
                    if (index > msg.Length) finished = true;
                }
            } else {
                index--;
            }
        }
        return msg;
}