- Home /
Question by
NikNax · Mar 03, 2018 at 08:00 PM ·
scripting problemerrorbuild-errorexportoncollisionenter
Collisions arn't working properly
So I currently have a problem as to when I build my game, the collisions arn't working properly.
private void OnTriggerEnter2D(Collider2D col)
{
itemPickedUp = col.gameObject;
if (col.gameObject.GetComponent<Item> ())
{
Debug.Log ("Colliding!");
col.gameObject.SetActive (false);
AddItem (itemPickedUp);
}
}
Whenever I run into an object with the component Item, it tells me that object reference is not set to an object(its talking about "itemPickedUp"). This functionality works perfectly fine when inside the editor, but when I export the game into a build, it gives this error. I need this solved due to the fact that the entire script relies on "itemPickedUp". I know its due to "itemPickedUp" because the objects would be disabled by the line "col.gameObject.SetActive(false);"
Comment
could you add the full stack trace from the debug console ?