Can't make my scoring thing work, maybe it's script? help
I'm new to programming (2,5 months in unity) and I'm trying to make a hyper-casual game (2D for android), and I'm currently having trouble with score, this is my game view, and here are all the scripts that I have, I really can't find the issue, I've been stuck on it for 2 days now and I've googled everything I could to find the answer, but I just couldn't
1 Reply
in PlayerColor script, all those methods are buttons (TurnRed, TurnBlue, TurnGreen, TurnYellow), except for DestroyPreviousCheck(), when any of those buttons are pressed, player changes to it's color, and instantiates a circle without sprite renderer, only a collider to check which color is active for it to then react and get a score if both collors are correct, which is now on the script called NewIfColor, it checks if the color of the player and the color of the object that's falling are the same, if so, then get a point (points are in GameManager script), if not, destroy the character(for now, later I'll make game over screen), and this is where the problem is, even though the colors are the same player does get the point, but he also loses, I don't know why, and also, even when the colors aren't matching, he will get a point and still lose, and I don't know why that is happening, why do I get this error:
"NullReferenceException: Object reference not set to an instance of an object
IfColor.OnTriggerEnter2D (UnityEngine.Collider2D otherCollider) (at Assets/Scripts/IfColor.cs:51)"
I get the same error but for different colors.
And spawn script is just a script that spawns the falling objects