Heli Merc: Moving enemies and graphical improvements E-mail
Thursday, 30 December 2010 14:11

I finally had some time over Christmas to get stuck into Heli Merc, starting with making some of the enemies move.

Rather than begin with the easy ones, such as the ground vehicles which can only move forwards and backwards, I decided to tackle a jet fighter. After creating the model, I set about modifying the enemy control script to have an "air plane" function.

To add some variety, I decided to make it so that the planes, once they have flown past their target (to start with, the player), will then execute a turn and come back for another pass. This looks like the plane rolls it's wings so that the camera is looking directly at the top of the plane, followed by a turn, then finally the plane will roll so that it's wings are level again. In order to avoid the well known gimbal lock problem, which in this case was triggered by rotating the plane on two axes, the rolling of the wings is accomplished by rotating the plane within it's local space, while the turn is performed by rotating the plane within the global space. There's various other ways of avoiding this issue such as calculating the rotations using quaternions, but it was just plain easier to do it the way I've done it for this case.

Graphics

The next thing to do was some more work on the graphics. I simply wasn't happy with the way things have progressed so far when it comes to the background, and the biggest issue is the limited resources on the phone. It's simply not feasible to have fancy graphics, so I've been trying out loads of different ideas to come up with something that I feel looks OK.

I really like the idea of the "sunset look" which I've been trying to achieve. Initially, I had the sun in the background and made the sky a flat colour, but it really just looks too plain.

A couple of days ago I had a brainwave though, and I decided to make the background bright and the foreground dark, so the vehicles and aircraft in the foreground are almost a silhouette against a bright sky and hazy hills on the horizon. This also needed a background texture, which is simply a shot of some clouds given an orange hue and drawn onto a large square polygon that's attached to the camera so it stays in place when the camera moves.

This started to look a lot better, but I felt that there needed to be some sort of highlight on the foreground vehicles to give them some depth, so I got rid of the sun in the sky and moved the light source so that it's almost coming directly from the left. I also cranked up the yellow and turned the specular settings right up on the enemies and the player giving everything a yellow glow.

The final touch was getting rid of the cactuses and rocks I had previously and just putting in some small spiky bits of grass that are randomly placed.

It all looks a lot better, but it's still a pretty sparse background.

Another new feature is that I've added a point light source that is switched on for a couple of frames at the location where a missile explodes, giving a nice little flash that lights up any nearby vehicles. The plan with this is to use it when a vehicle explodes, but for now it's happening all the time.

Performance

And so yet again we encounter the biggest issue that I'm having with this project: the frame rate. Prior to my graphics improvements I was getting somewhere around 28 frames per second on the phone which would drop down to about 18 fps when the helicopter was close enough to the ground to trigger the dust whirlwind particle emitter.

With the latest changes, and having removed the dust particle emitter, I'm getting about 24fps, dropping to about 18fps when all the enemies are on screen at once and the player is flying near the bottom of the screen, so that they are all visible.

I've tried compiling versions of the game with various features turned on and off. The background cloud graphics seems to be eating 3 frames per second of overall performance. The fog effects consumes another 1 frame per second, the explosion point light takes 2 frames per second, and the bright yellow highlights seem to be sucking up about 3 frames. It's not much individually, but add them up and It's getting slow.

It should mention that it was worse than this before, crawling along at 10 frames per second. I had to tidy everything up as I was using too many textures and materials. I combined the individual textures into one 512x512 pixel atlas that is used by everything. There's now only three materials in total, one that is affected by fog, one that is not and a final one that is shared by all the vehicles to give that shiny effect.

The vehicles currently have no texture and are still just grey coloured.

The next step is to work on the performance further, and perhaps put some sort of options menu to turn off features like the explosion flash for slower devices. I'm sure there's still more than can be done to speed everything up though, so I'll keep investigating.

Things will start to get easier moving into next year when the dual core Tegra 2 phones start to hit, and even then, the Galaxy S is still pretty quick. I'm doing my testing on my HTC Desire which has pretty average 3D performance, so if I can get it running OK for that, it should be fine on the Galaxy S or higher.

Try out the latest version discussed in this blog post!

Return to the Heli Merc section!

blog comments powered by Disqus