Gamieon is a one-developer part-time studio focused on creating video games for the desktop and mobile platforms. Since 2010 Gamieon has developed and released six games as well as six more prototypes. Including beta distributions, Gamieon's products have netted a combined 300,000 downloads! Below this bio are images from all my games and prototypes. Check them out and don't forget to follow me on Twitter @[Gamieon](members:gamieon:321769)

Report RSS Optimizing Unity iPhone/iPad app physics usage

Posted by on

Hyperspace Pinball's recent iPhone 3GS performance was lackluster at best. According to the standard profiler: At the start of a game where eight enemies were floating around and the ball was at rest, the amount of time physx is taking per frame averages 6.1 while scripting Updates() took between 8 and 10. What could be going on with physx to make it so time intensive? Well, I figured it out; and managed to get the usage down to 3.5. I'll now share with you how based on my own experiments and content from:

Unity3d.com
Roperacket.tumblr.com

1. Colliders - Remove unneeded colliders and combine colliders into one.
I did this earlier; so no changes here.

2. Overlapping colliders can produce as many as 3 solving iterations per each frame so pay special attention when forcing position on an object with a collider.
This was definitely a problem. I had a lot of overlap in the colliders that confined the aliens to the center of the playfield. I simply fixed the overlap without changing the inner bounds.

3. Use simpler colliders – sphere is simpler than cube, which is simpler than mesh collider.
I noticed some of the playfield colliders were mesh colliders shaped like boxes. I also noticed the curved edges of the bottom bumpers and side "bumpers" were making things add up. I solved this by replacing mesh colliders with box colliders, and also going into 3DSMax 3.1 (yes, 3.1), making simple shapes, exporting them, and importing them in as invisible mesh colliders to replace the existing colliders. I'm fairly sure this got me the biggest performance bump.

So after steps 1-3, the average physx time went down from 6.1 to 5.2. That wasn't as big a drop as I had hoped for, but I'll take it!

I was about to give up until I stepped away for a while, and suddenly step 4, which I didn't see in any optimization suggestions that I read before, came to mind:

4. Turn off unnecessary layer a-layer b collisions
The enemies were doing collision checking against the playfield. The problem with that is I already fenced in the enemies with box colliders so they would never actually touch the playfield! So, I went to the Edit menu => Project Settings => Physics, then disabled Enemy Latyer-Playfield Layer collision detection, and ran a test:

The average physx time went down to 3.5!

Definitely a good sign. After that, I went through the entire physics matrix looking for anything else I could optimize. The only other item layer that needed correcting was the power-up ball, which is also fenced in by the same boundaries.

So, good progress all in all. I'd like to go for 2.5, but for now I'll turn my attention to optimizing how I use the Vectrosity wireframe glow engine (thats how the enemies get their glow. Check out the engine at Starscenesoftware.com )

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: