Hi,
I’ve been working on a drop and boost system in my game. When enemies die, some boxes drop and when player collides, boxes disappear and boost works.
Enemies are spawning from random spawn points and when there is no enemy on the scene, I cannot take the drop, in other words player cannot collide with boxes and boxes do not disappear. Also, I take this error on the console “object reference not set to an instance of an object”. I have tried to modify the script a couple of times but it did not work, unfortunately. You can see the last version of the script below.
private void OnTriggerEnter2D()
{
if (GameObject.FindGameObjectsWithTag(“Enemy”).Length >= 0)
{
FindObjectOfType<.Enemy>().enemySlowdownBoost(); (Problem is here, as console shows)
Destroy(gameObject);
}
}
Can you help me to fix this issue, please?
Thanks for the help.