Error on my enemy destroyed

Capture

What could be the issue? If i increase my enemy health and my first enemy doesn’t die, then my enemy’s will respawn but they respawn with low health. If my first enemy dies then i get the error above and the enemy dose not destroy itself and stops enemy spawn. Here are my Enemy Spawner and Enemy Damage Scripts.

Hi,

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Since the error message mentions a missing reference (“link to an object”), check whether something was assigned to the exposed variables in your Inspector.

Hope this helps :slight_smile:


See also;

Is your enemyPrefab a referance to a prefab, or an instance? If it’s an instance and you destroy it, you will have a broken referance, might also explain the weird health glitch.

Hope this helps!

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

Privacy & Terms