NullReferenceException: Object reference not set to an instance of an object.

Is your particle system assigned to the field in the Inspector on your script?

A Null Reference Exception (NRE) is caused when you’re trying to access a method or property on a null object – in other words, trying to get something from nothing.

Pretend I give you a set of instructions:

  • I will hand you a package of Oreos.
  • Open the package
  • Take out a cookie.
  • Eat the cookie.
  • Close the package.

I hand you the package, you open it, and the container is empty. Your “code” would fail at line 4, because you’d be trying to eat a cookie that doesn’t exist. That’s an NRE.

@Kurt-Dekker gave you some great tips on how to find that problem. @MartinMa just straight up gave you the answer. What part are you having difficulty understanding?

2 Likes