Multiple Enemies Not Spawning


I did the code for my “EnemySpawner.cs” script right in section 99 of the Laser Defender course, but I’m getting the “NullReferenceExperience” error in my game when I press play. Furthermore, when I deleted my enemy, a new enemy did not spawn. The error is located in my “EnemyPathing.cs” script, but I don’t know where to find it.

Hi Bilal,

NullReferenceException means that a reference (“link”) to an instance is missing. Double click on the error message to see to which line in your code it is referring. If you exposed a field in the Inspector, make sure that it’s not empty.

Do not assign an enemy from your Hierarchy to your enemy prefab variable because if that enemy gets destroy, no new enemies can get spawned anymore.

See also:

Thanks for the info, but I am using a MacBook, which means whenever I click on the error, it doesn’t specify the line of code.

I figured it out. It turns out I didn’t set the wave on the enemy prefab.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms