Group Group Group Group Group Group Group Group Group

NullReferenceException in chapter 8

Hello there,

I have a problem in chapter 8, with a NullReferenceException in this line in the GameManager’s Update() method: alienScript.GetDeathParticles().SetDeathFloor(deathFloor);

I think the variable public GameObject deathFloor is not selected correctly in the Unity Editor. I upload a picture to show the process I have followed.

Can you help me?

Hey There … Sorry to hear you are having issues. Looks like something hasn’t been set or maybe a typo. A good way to debug this is to break that line into two separate lines.

So try setting the line to be:

var deathParticles = alienScript.GetDeathParticles();

Then try the game again. That should tell you where the null pointer is coming from, and from there, we can determine the cause of the issue.


I had the exact same issue. What I found was that I missed this:

“In the Project view, expand the Alien prefab and select the AlienDeathParticles GameObject. Click Add Component and under scripts, choose DeathParticles.”

I could have sworn I did that step, but maybe I did it to the alien in the scene prior to deleting him, and I forgot to apply it to the prefab.

1 Like

I had the exact same problem. Thank you!