I am making a game for school project using unity 5
I want the player to score on collision, So if the player touch the coin it gives you 1 point to the score i have it working when the player touch the coin it get destroyed. I looked lot about this but are outdated for unity 4 etc…
Have an int to store the score against & in your oncollision that you have working add 1 point to the int before you destroy the coin.
This is my coin pickup script
2406389–164349–PickupCoin.cs (393 Bytes)
yeah at this stage, you can create a variable called “score”, and then in the OnTriggerEnter2D() function, just increment the score value (score++; )
Depending how you structure the game find something that will always be in the game scene or create an empty game object as a manager & store the consistent things like score, player lives etc on that. Create a reference to the manager script in the start function of your coin script or player script (depending where you are detecting the collision) & then when you pick up the coin use that reference to the manager script to pass the value across.