Stuck on NullReferenceException

I’m making my first rudimentary game and I’ve come across this numerous times. Each time it usually comes down to just dragging the right object into the right slot on the inspector.

This time though the specific line it is referencing doesn’t seem to have anything to do with this idea. For reference, this came about when I made a bird object a prefab, so another object spawns one every four seconds. The player can shoot the birds and once their health is below 1 the birds fall. I set their motion via adding force, so changing its gravity should work to make it fall. It did exactly that… before I made it a prefab.

What’s odd is that the first click on a bird (which takes away 1-2 health) shows the blood animation. It’s only on the second click where I get the error, but the message equalz is still printed. Thus, I know that everything below is getting executed, which is odd because both of the ways I tried to apply gravity didn’t work.

Essentially, the bird recognizes the bullet the first time it collides with it, but doesn’t recognize it after that.

Either your reticleScript reference is null or your Rb2d reference is null. Those are the only two references inside your OnTriggerEnter2D method that could be null.

ps: Why do you set Physics.gravity when you use 2d physics? You’re either doing some strange hybrid game where you use both physics engines at the same time, or you’re doing something wrong. I guess the latter ^^.