OnTriggerEnter and Exit issues

I have a monster that chases NPCs when they enter this trigger. When he kills them, they instantiate a ragdoll and destroy(usual stuff). However, the target variable in inspector has a “missing.”(component, I’m guessing), and this throws me off. Is destruction of an asset not the same as exiting the trigger?

//I don't have my code on me but this is essentially what it says
void OnTriggerEnter(Colider other)
{
	if(other.CompareTag("Survivor"))
	{
		target = other.transform;
	}
}
void OnTriggerExit(Colider other)
{
	if(other.CompareTag("Survivor"))
	{
		target = playerTarget;
	}
}

I did this check using distance instead of triggers and it worked fine. With this I wanted to use triggers instead of distance for testing.

‘Missing’ on a reference field means there was a non-null reference there before, but it was destroyed at some point.

That means you’re destroying your character object correctly, which causes all references to it to become null.

Your example there isn’t very helpful though, we don’t know what playerTarget is, or where else it’s being used, or even what throws the null reference exception and when.

If you could post some more detail on the problem, we might be able to help figure out where it’s going wrong.

Cheers

Actually, you kind of answered my question. I didn’t realize that destroying the reference was not good. Is there a “if (object.destroyed)” check so I can set it to null?