Android game crashes and closes when collecting collectible
I'm currently making an Android game (it's my first one) in which you can collect rotating coins (in fact they are just white cubes.) The code for collecting them looks like this:
public class Collect : MonoBehaviour
{
[HideInInspector]
public Text collectiblesText;
private GameObject collManager;
void Start()
{
collManager = GameObject.Find("CollectibleCounter");
collectiblesText = GameObject.Find("CollectiblesText").GetComponent<Text>();
}
void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "Player")
{
collManager.GetComponent<CollectibleManager>().collectibleCount++;
collectiblesText.GetComponent<Text>().text = collManager.GetComponent<CollectibleManager>().collectibleCount.ToString();
PlayerPrefs.SetInt("Coins", collManager.GetComponent<CollectibleManager>().collectibleCount);
gameObject.SetActive(false);
}
}
}
In the Unity Editor everything works fine, but the actual Android game crashes and closes when collecting one of these coins. Please tell me if you see the problem or just know some good Android debugging tools. If you miss some important information, write a comment and I will add it.
Thanks for your help, Luke
Screenshots:
Overall view with coin selected
Overall profiler at frame of collecting
Your answer
Follow this Question
Related Questions
android crash at Failed to open file: /system/lib/librs_jni.so 0 Answers
FMODAudioDevice Crashing in Android 4.4 3 Answers
Unity 5.3.1: Baked scene crashes Editor on Mac 4 Answers
android app crashes for no logical reason 0 Answers
Performing stop of activity that is not resumed: com.unity3d.player.UnityPlayerActivity 0 Answers