Painfully slow on Android?

My game works perfectly on the PC and on the Web, but as soon as I demo it on an Android phone its running like a flip book. My Drawcalls are 375ps. All my code is in Javascript. There are only 4 main moving objects in the game. and about 36 static walls. 3 lights. Do the project files that are not being used in the game affect the speed? Its completely unacceptable. I’ve created a First person tunnel game so the FPC is always in foward motion. Does anybody have any ideas why the game play is like swimming in quicksand? Could it have anything to do with the way I loaded the JDK and the SDK? This is the first time I’ve run the game on the phone(Android)? Any suggestions? Thanx

Here is the forward motion script I’m using(its from the Tunnel Runner Demo)

var rotateSensitivity : float = 4.0;
var moveSpeed : float = 6.0;
var controlCurve : ControlCurve;
private var rotationCurve : AnimationCurve = AnimationCurve.Linear (0,0,1,1);
private var acc : Vector3 = Vector3.zero;

function Awake (){

// In order to make the feel of the player controls
// consistent in all levels, we set this property in awake.
// This way, each level's instance of the camera can inherit response
// curve that has been set up in the Prefab called "Control Curve"

// Note: To edit the master response curve, select the
// "ControlCurve" Prefab in the Resources folder, and
// select GameObject->Edit Response Curves from the menubar
rotationCurve = controlCurve.controlCurve;

// Set Phone to widescreen mode
 Screen.orientation = ScreenOrientation.LandscapeLeft;

}

function Update (){

// Move the camera and children forward

   transform.Translate (0,0, Time.deltaTime * moveSpeed);

}

function FixedUpdate (){

// Smooth out the value coming from the device

       acc = Vector3.Lerp(acc, Input.acceleration, 0.65);

// Determine the final value of rotation based on the response curve

       var filteredRotation : float = rotationCurve.Evaluate (Mathf.Abs (acc.y));

// Invert the evaluated rotation value if we're rotating left instead of right

        if (acc.y> 0){

	    filteredRotation = -filteredRotation;
}

// Apply the final rotation

   transform.Rotate (0,0, filteredRotation * rotateSensitivity);

}

I’d guess that you have way too many drawcalls. Our game currently has a maximum of maybe 40 draw calls at any time, and even that is pushing it a bit. You should really be trying to keep your draw calls within the 20-30 range.

Since you have way more than that, you might want to explore ways to reduce this. Here are some possibilities:

  • If you have static items, mark them as static and use static batching (unfortunately, a Pro feature).
  • If your dynamic items have more than 300 vertices, they will be batched if they share a material.
  • Skinned meshes can’t be batched; major hog of drawcalls if your game requires them!
  • Try to get as many objects as possible to share materials.
  • Reduce the number of objects on-screen at any one time.
  • Sometimes the z-order of objects can affect the number of draw calls.
  • Sometimes it seems that objects that are not of 1,1,1 scale do not batch.

You may also look into using simpler shaders. Using highly specialized shaders on your objects as opposed to generalized ones can make a big difference; a recent pass on our game’s shaders gave an ~10fps boost!

Also, if your game is physics heavy, this can be a major performance hog. You’ll need to limit the time the game spends on physics.

From the stats you’ve given, it seems that you have not designed this game with the performance limitations of Android devices in mind. Unfortunately, it may not be possible for you to make some small tweaks to get it working correctly; you may have to make some substantial changes to get it running at a good speed.

Maybe you want your game installed on the internal phone’s memory. Some SD cards are slow.