Hey All, here is your answer:
Note please put this script onto your "Player" only:
var score = 0; var scoreText = "Score: 0"; var mySkin : GUISkin;
function OnTriggerEnter(other : Collider ) {
if (other.tag == "Pickup") { //Pickup is the tag please replace it with your pick-able item tag
Debug.Log("Other object is a coin");
score += 1; //You can replace 1 with any integer this is you score
scoreText = "Score: " + score;
Debug.Log("Score is now " + score);
Destroy(other.gameObject);
}
}
function OnGUI () {
GUI.skin = mySkin;
GUI.Label (Rect (200, 10, 200, 400), scoreText.ToString());
}
Note:Mark this answer as correct, Thank you.
Trending Articles
More Pages to Explore .....