# Unity - Code is fine in the editor, has error on android

Right. Im running into some weird issue with android unity. I have this bit of code

function OnTriggerStay (other : Collider)
{

if(die.GetComponent(DieScript).sideUp ==6 ||die.GetComponent(DieScript).sideUp ==2 || die.GetComponent(DieScript).sideUp ==4)
{

parSys.startSpeed = -5;
if (other.attachedRigidbody)
{
var direction = -(other.attachedRigidbody.transform.position - transform.position*1.5);
}

}


Now, this runs fine in the unity editor. More then fine, It runs perfectly. However on android the whole OnTriggerStay method fails, and I get this error from logcat

I/Unity   (29199): NullReferenceException: Object reference not set to an instance of an object

I/Unity   (29199):   at ZoneScriptDie.OnTriggerStay (UnityEngine.Collider other) [0x00000] in <filename unknown>:0

I/Unity   (29199):

I/Unity   (29199): (Filename:  Line: -1)

I/Unity   (29199):

I/Unity   (29199): NullReferenceException: Object reference not set to an instance of an object

I/Unity   (29199):   at ZoneScriptDie.OnTriggerStay (UnityEngine.Collider other) [0x00000] in <filename unknown>:0

I/Unity   (29199):


Why is it failing in android? The whole object freezes up, the particles just hang in place like a frozen snowglobe.

• If you put a lot of debug output in there, you could narrow down the precise line the null reference is occurring on. If I had to guess, it's possible that die may be the object that doesn't have a reference. – chaosTechnician Dec 29 '12 at 6:16
• Unfortunatly. Thats really all the debug out put I got from Logcat, Its just repeats a bunch of times. link And in start I have parSys = GetComponent(ParticleSystem); die = GameObject.Find("die"); So It should exist. It exists and runs fine in the editor, but not on android. Ill try playing with how it finds the object – ProtoJazz Dec 29 '12 at 6:35
• Maybe There would be a better way to log the date? Or would all the non unity debug help? – ProtoJazz Dec 29 '12 at 6:41

die = GameObject.find("die"); //Worked fine in the editor to die = gameObject.transform.parent.gameObject;