✅ I might be stupid, but my score system adds two every time a collision happens instead of one.
I can't figure out why. Then again, I don't know what I'm doing. I'm following a tutorial and this is the code he used, only his worked.
11 Replies
I would have expected it to work like this:
Player Score = 0 + 1
Player Score = 1+1
But it doesn't. It just goes 2, 4, 6, 8 and so on
We need to see your collision code
Your issue isn't the addScore code but the collision code.
Assuming it is Unity, it might call collide multiple times
Do you only want to add score one time?
If so then you can add a state whether score was given or not.
If it hasn't been given then add score and then set the given state to true.
One point per collision
Do you have multiple triggers?
No. There is only one thing that causes the score to go up
What you could do is have a state as I mentioned.
Set false on trigger exit and true on enter
Something like that
Ah that is easier then my work around.
I don't fully understand all of it though so I'll have to do some readiing
Changed it so you don't have to worry about properties .. For now. 😛
Whoops, I accidentally had it as an int datatype when it should've been a boolean, my apologies
Ahhh that makes more sense
I found a scummier work around though. It's ugly but
I just needed inspiration I suppose
Testing it now
Never mind
Even if it worked it would have been idiotic