Object exception that does not make sense

So I have this code that always works on other projects, but this one was not working. I keep getting this


My Code. C#

using UnityEngine;
using System.Collections;

public class Destruction : MonoBehaviour {

public GameObject object1;
public GameObject object2;

// Use this for initialization
void Start () {

	object1.SetActive (false);
	object2.SetActive (true);


void OnTriggerEnter(Collider other){

	object1.SetActive (true);
	object2.SetActive (false);



Well, the exception is quite clear what happens. The variable object1 seems to be null. So you either don’t have assigned an object in the inspector or the object might have been destroyed.

Try a single click on that error message in the console. It should highlight the object in the hierarchy (a yellow background that should be visible for a second). Select that object at runtime when the error occured and check it’s object1 variable in the inspector. Does it have an object assigned? Most likely it doesn’t