Can't get object to be reactivated by parent.

Hi everyone,
I’ve been breaking my neck on this problem for a few hours now and since I can’t find any info that helps me anywhere apparently, I’ve come here to ask for some help. I know what the issue is, I think, but I dont know how to work around it or solve it.

So I have an emptyobject (Ill call it weapon) with a trigger on it, and when it collides with an object tagged as “enemy”, the weapon’s script sets a boolean in the script of the enemy it’s killing, “dead”, to true. This is just some background.

When dead becomes true, it sets the Enemy-object to inactive. After this a cooldown comes up (supposedly), after which the enemy becomes active again. (As a form of respawning.) Herein lies the problem (I think): The parent cant activate the inactive child, because the code of the child cant be reached BECAUSE the child is inactive… like a vicious cycle?

Please, if I got this all wrong, do explain it to me! Im really eager to learn and I’ve only gotten started like a week ago. Thanks for your time in advance!

The code of the EnemyController, the script on the Enemy itsself:

public class EnemyController : MonoBehaviour {
	public float knockBackX, knockBackXneg, knockBackY, stunTime;
	public bool dead;
	public bool activated;
	public GameObject enemyPrefab;
	public float currentcooldown, recooldown;

	void Start () {
		dead = false;	
		activated = true;
		gameObject.SetActive (true);
	}

	void Update () {
		if (dead == true){
			activated = false;
			gameObject.SetActive (false);
		} 
	}
}

The code of the parent of the “enemy” object:

public class enemyParent : MonoBehaviour {
public int currentcountdown;

	void Start (){
	}

	void FixedUpdate () {
		if ((GetComponentInChildren<EnemyController> ().activated == false) && (currentcountdown != 20)) {
			currentcountdown += 1;
		} else if ((GetComponentInChildren<EnemyController> ().activated == false) && (currentcountdown == 20)) {
			GetComponentInChildren<EnemyController> ().dead = false;
			GetComponentInChildren<EnemyController> ().gameObject.SetActive(true);
		}
	}
}

Oh and last but not least, when I destroy the enemy, it gives me an error that keeps stacking rapidly, up to a few hundred in a few seconds. This is the error:

NullReferenceException: Object reference not set to an instance of an object
enemyParent.FixedUpdate () (at Assets/AI/enemyParent.cs:8)

When the Object become SetActive = false; the object also becomes null, so that answers the null reference exception. However, as for the Parent not being able to set the child to active, i would try using the enabled method instead. It takes a boolean argument as enabled = true or enabled = false . This can be changed by another script while still setting the game object to be inactive or active. Now if you want the object to disappear when it becomes deactivated, you have to options, SetActive which we seem to have a problem with, or you could actually use the Destroy() method as an alternative and instantiate a new one after time has elapsed. Either of these methods, I suggest having a Game Manager that controls game functionality such as Object Activation/Deactivation because this will allow you to have a little more functionality, if you’d like any examples of any of the three methods, just let me know.