I’m working on a game using Unity 4.6 that requires a terrain collider and a collider placed in the sky. The objective is to keep the character on a platform and to accomplish goals without it falling off. If it falls off, it hits a collider on the terrain and the level restarts. If all objectives are accomplished, it shoots off into the sky and hits a collider that triggers a new level load.
This works fine when exporting to BlackBerry, Linux, Windows, and web. Unfortunately, when I try exporting to Android, I get a slew of
Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
errors. When I load the .apk on Bluestacks, a lot of the colliders do not respond to impacts and the ball continues flying off into the sky or falls thorugh the terrain.
I’ve tried completely rebuilding new terrains and colliders in the sky as well as rewriting the script attached to the character. Nothing seems to be working and I’m really getting frustrated. (I actually had to pull the game off of Google Play).
Script below, although I don’t think that it’s my problem. I’m sorry for it being messy; this was after the rewrite.
using UnityEngine;
using System.Collections;
public class LevelKill : MonoBehaviour {
GameObject[] gos;
int remainder;
public string Loadlevel;
public string thisLevel;
string remainderstr;
bool levelkillbool = false;
public bool manualKill = false; //For debugging purposes.
float SW = Screen.width;
float SH = Screen.height;
public float FinalEnergy = 200;
// Use this for initialization
void Start () {
gos = GameObject.FindGameObjectsWithTag ("Ring");
}
// Update is called once per frame
void Update () {
gos = GameObject.FindGameObjectsWithTag ("Ring");
remainder = gos.Length;
//if no more objectives are left, shoot off into the sky
//same of manualKill
if (remainder == 0 || manualKill == true)
{
rigidbody.AddForce (0, FinalEnergy, 0);
levelkillbool = true;
}
//show the number of objectives left at the top of the screen in a button
//Not to future self: replace this with a GUITexture instead of a button
if (remainder > 0)
{
remainderstr = remainder.ToString();
}
}
//This provides a button with the current number of objectives left and
//gives the user the option to press the button to advance to the next level
//if this level is complete.
void OnGUI(){
if (GUI.Button (new Rect (calc (0.40f, 1), calc (0.01f, 2), calc (0.2f, 1), calc (0.1f, 2)), remainderstr)) {
if(levelkillbool == true)
Application.LoadLevel(Loadlevel);
}
}
//if I'm hitting the terrain or sky-collider
void OnCollisionEnter(Collision hit)
{
if (hit.gameObject.tag == "killer")
Application.LoadLevel (Loadlevel);
if (hit.gameObject.tag == "restart")
Application.LoadLevel (thisLevel);
}
//some basic math for finding the width of the screen to position the button
float calc (float a, int b){
float ret;
if (b == 1) {
ret = a * SW;
return ret;
} else if (b == 2) {
ret = a * SH;
return ret;
} else {
return 1.0f;
}
}
}