game object set active on trigger enter?

I’m trying to make a jetpack pick up object, so that when you run into the jetpack that is laying on the ground, it destroys from the ground, and then i want to set my jetpack gameobject to active, that i have on my player, which ive set to false as default so its not showing. Ive got the code attached to the jetpack object, but its not working, just giving me a null reference exception, am i missing getcomponent somewhere? please help, thx :slight_smile:

Heres my code as following:

void OnTriggerEnter2D(Collider2D other)
	{
		if (other.tag == "Player") 
		{
			GameObject go = GameObject.FindGameObjectWithTag ("JetPack");
			go.SetActive (true);
			Destroy (gameObject);
		}
		
	}

I don’t think it is possible to activate an object when it is inactive (sound stupid but I tried it out) the gameobject has to be checked to let the script work.

Instead you could just de-activate the render of the jetpack on the player and when the player collide with the jetpack on the ground the render is set to true.

void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player") 
        {

            GameObject.Find("JetPack").GetComponent(Renderer).enabled=true;

//activate the JetpackScript
gameObject.GetComponent<TheJetpackScript>().enabled = true;   

     // Destroys the jetpack that is on the ground 
            Destroy (gameObjectWithTag("JetpackOnTheGround"));
        }
 
    }

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

public GameObject cubes;// Object to active
public float sec = 14f;

void OnTriggerEnter(Collider other)
{
	if (other.tag == "JetPack") { //tag name Object to Pick Up
		
		cubes.SetActive (true);
		StartCoroutine (LateCall());
		Debug.Log ("JetPack Ready");

	}
}

//after same sec Object to false

IEnumerator LateCall()
{

	yield return new WaitForSeconds (sec);
	cubes.SetActive (false);
	Debug.Log ("JetPack Diactive!");
}

}