Skip to content

Instantly share code, notes, and snippets.

@WakkyFree
Last active April 3, 2018 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WakkyFree/ac5cf407e53cc6624ea64b1fd7eed380 to your computer and use it in GitHub Desktop.
Save WakkyFree/ac5cf407e53cc6624ea64b1fd7eed380 to your computer and use it in GitHub Desktop.
Unity script to add score
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class AddScore : MonoBehaviour {
private int score = 0;
public Text scoreText;
// Use this for initialization
void Start () {
score = 0;
scoreText.text = "0";
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter(Collision collision) {
if (collision.gameObject.tag == "Wall") {
score += 100;
scoreText.text = "" + score.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment