Player ship explosion is not triggering upon hitting an enemy object

Somewhere along the next lecture, my player explosion VFX has failed to work properly. My enemy explosion VFX works perfectly fine but my player explosion VFX does not work at all. This error appears in the editor

This is my collisionhandler script

Hi Jacob,

Welcome to our community! :slight_smile:

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.

Did this help?


See also:

Hi Nina, for some reason, when i double click the error message, it doesnt lead to any line of code.

Both the prefab and the instance of the player is not exposed to an empty field or so I believe

When exactly does the error message appear? Maybe the player root game object gets destroyed, and the code still tries to run one of the particle system of the “destroyed” game object. Do you happen to call the Destroy method anywhere?

For testing purposes, comment out the line where the level gets reloaded after 1 second. Then test your game again.

After doing some test runs, the error message still appears and the player ship still doesn’t explode. When I double-click the error, it still doesn’t lead me to any scripts.
The only scripts in which I have placed Destroy are on the enemy script and the self-destruct script. After commenting out the line where the level gets reloaded, there were no significant changes.

After rewatching the video, I realised that I used the prefab version from my assets folder. I should have used my prefab version which was attached to the playeship in the hierarchy

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

Privacy & Terms