I know there’s a lot of questions asking this question but the answers on the other questions don’t seem to have any luck with me. This is what I have:
public GameObject missile;
void OnTriggerEnter(Collider collide)
{
if(collide.gameObject.name == "powerup2")
{
Debug.Log("hit");
//EnemyAI.speed = 2;
missile.GetComponent<homingMissilePlayer>().enabled = true;
Destroy(collide.gameObject);
StartCoroutine(enemySpeed());
}
}
It’s giving me this error though:
NullReferenceException: Object reference not set to an instance of an object
The homingMissilePlayer script is on one of my missiles that is instantiated every few seconds, but I have dragged the prefab of the missile onto the object this script is on.
Can someone please tell me what I’m doing wrong please?