Question by
stahzui · Apr 27, 2016 at 09:40 AM ·
javascripterrorscore systempoints
Keeping points tallied
Hey all!
I'm currently working on an arcade style game where you fire spheres at targets to gain points. Something is not quite right with part of my code, though. Whenever the player character fires at another object, the score resets instead of adding onto itself.
I'm still pretty bad with programming and sort of threw this together with help from a friend:
import UnityEngine.UI;
var ScoreManager : Text;
var score : int = 0;
function OnCollisionEnter (col : Collision){
if(col.gameObject.tag == "Bullet"); {
score += 0;
ScoreManager.text = score.ToString();
What exactly am I missing? Thank you for your time!
Comment
Answer by HarshadK · Apr 27, 2016 at 10:21 AM
Your score is not resetting but staying the same as you are adding 0 to your existing code at
score += 0;
Instead of 0 you need to add the amount of score you want to add after player fires another object. Something like in code below it is adding 10 points:
score += 10;