iOS framerate problem

Hello. I am currently working on a Gradius type game (I am trying to emulate the graphics and gameplay of a nes era shmup) for the iPhone. Although it works fine inside Unity, I am running into some problems when I try to run the game on an iPhone 4. The framerate take a slight dip that is just enough the throw off the gameplay mechanics. I cannot for the life of me think of what is causing the game to slow down. Could someone please take a quick look at my project and see if they could find any problems with it?

I know that is alot to ask, but as I said before, the game isn’t very complex (it consists of two scenes and one of those is the main menu). The speed issues extend to both the main menu and gameplay scenes.

If that is too much to ask, here are the stats from my game (not very taxing to the system)
-No more than 11 draw calls
-Max of 500 Triangles and about 1.1 Vertices
-10 used textures (4.7mb)
-7.8 to 11 mb of VRAM
-No animations, shadow casters or visible skin meshes

Thanks.

Heya Tofudude624

I don’t really want to download your project, but I would be happy to help you out over skype. Send a PM and I’ll see what I can find for you. At at guess its going to be a fill rate issue since its happening on an iPhone 4. Probably just need to replace your shaders with something more IOS friendly and build some geometry around large alpha planes.

Are you sure the framerate issues are GPU-related? When you say ‘Gradius type game’, I immediately think “large number of objects”. If you’re allocating and deleting a lot of things at runtime, this can be quite GPU-intensive, especially when the garbage-collector kicks in. If it’s an intermittent problem rather than a constant slowdown, that’s the first place I’d look.

Well, it is not like one of the more recent gradius games, so there the number of enemy ships/bullets on the screen is relatively small. You mentioned deleting a lot of objects, could the player’s projectiles be the cause of some slowdown? They are spawned every half second and are destroyed within 1 second.

Hard to know for sure without testing, but in general any time a game requires many of the same object to be created and destroyed continuously, it’s better to allocate a pool of those objects upfront* and just disable them when not in use. If nothing else it reduces memory fragmentation and any garbage collector stalls.

*unless you can’t always fit that many in memory at once, but that’s going to cause problems regardless.

If you are seeing the FPS drop in the Main Menu and you are not presumably allocating /destroying constantly in the Main Menu. Are you sure its not a fill-rate issue? The iPhone 4 really doesn’t like heavy fill bound scenes.

Spawning and destroying could be heavy on your app. Try minimizing the amount of objects that are spawned and see if it’s running faster.

Okay, basic question…what does “fill-rate” mean?

Fill-rate is proportional to the number of pixels you draw. Every object you draw on top of another adds to this.

Better to draw lots of small polys on screen than a few large/full screen polys that take up more pixel space on screen.

Internal profiler is your friend: Unity - Manual: Measuring performance with the built-in profiler . Once you have some stats it is much easier to help you.

I’ll check the profiler out.

That could explain things. I am not using a lot of meshes to display my HUD (it is styled after this…except all of the menu stuff at is just one texture with the score and high score variables displayed as GUI elements). Also, I might be using alpha channels too much. Take that HUD texture for example, the mesh actually takes up the entire screen…should I just scale down the texture to use only what I need? One more thing, to better organize my project files I am not using materials very often. Rather I just attatch this script to most of the objects in my game…could this be the cause of some of slowdown?

var Art    : 	Texture;

function Start   (){
	renderer.material.shader 	  =  Shader.Find( "Transparent/Diffuse");
    renderer.material.SetTextureScale         ("_MainTex", Vector2(1,1));
	renderer.material.mainTexture =  Art				;
}