#I fail to understand
1 messages · Page 1 of 1 (latest)
In the unity console it should point you to a line
Show me the code block for whatever line 18 is?
so yeah in the Start() method, set ScoreManager.Instance.score =0
doesnt that make the score reset every time an enemy spawns?
I just realized something
ScoreManager is a subobject to BulletBoard
would that be causing the issue
shouldn't it be BulletBoard.ScoreManager.instance.score or something?
No idea. Without looking at ALL your code, its hard to tell. But Conceptually the reason you are getting that issue is cause score = null at the time you are trying to += it.
So You need to set the score to 0 before you try to add to it
so maybe the Score Manager needs to be set it to 0 on wake?
ye
isnt score an int?
nah some other ppl were saying that the int is null too np
I was about to say
Every time I have worked with an unset integer that is serialized or public, it shows a 0
yeah floats and ints are initialized as 0
but now you gotta figure out why your instance is null
(i suppose)
shouldn't your code just be ScoreManager.score = 0'?
Or am I missing something
I mean score +=
if it was static score then yes, but its not, so it needs instance reference
does the fact that ScoreManager is a SubObject to BulletBoard (which is present in the scene) mean anything?
not inherently..
okay
I'm going to chalk this up to me bieng an idiot and tired lol
I'm sure the solution is super simple too
Only in unity
only Unity is complaining
just put Debug.Log("ScoreManager instance exists: " + (ScoreManager.instance != null));
before line 18
^^
could I put that on Start instead?
because line 18 is only reached if the object gets shot
Yeah but that is where unity is pointing
Easier to just but it right before to avoid any weirdness
When in doubt Debug.Log out i guess
Debug.Log is your friend
make sure you have only 1 ScoreManager in scene
It IS deleting itself
At this point I wish there was something like ctor for Debug.Log
wait wtf is even that
ctor?
if(instance == null && instance != this)
i think it should be if(instance != null && instance != this)
it supposedly checks for other instances
did you make sure you gave only 1 ScoreManager in scene
yep
this is it
whoops
yeah pay attention to what you copy 😆
wdym by this?
"Click to open rate"? or Constructor
no idea i just googled it lol
how would you use a constructor for Debug.Log
if you do Debug.Log("ASD", gameObject), it holds a reference to the object