So I'm trying to make a flappy bird type game. I want my bird to only get points when it is alive since when it dies, sometimes it ragdolls a bit and it gets a point. So this was my add-point statement originally: Code (CSharp): private void OnTriggerEnter2D(Collider2D collision) { logic.addScore(); } So I wanted it to not get points anymore when it dies, so I changed it to this: Code (CSharp): private void OnTriggerEnter2D(Collider2D collision) { if(neilscrip.birdIsAlive == true) logic.addScore(); } It should have fixed the problem, but now my bird isn't getting any points. When I pass through a pipe, instead of getting a point, I get an error code: "NullReferenceException: Object reference not set to an instance of an object PipeMiddleScript.OnTriggerEnter2D (UnityEngine.Collider2D collision) (at Assets/PipeMiddleScript.cs:24)" My PipeMiddleScript.cs.24 is: Code (CSharp): if(neilscrip.birdIsAlive == true) What can I do to fix this?
Thank you so much! I was confused since my pipe isn't actually spawned yet so I'd have to reference it using tags. Thanks!