Last active
April 3, 2018 22:36
-
-
Save WakkyFree/ac5cf407e53cc6624ea64b1fd7eed380 to your computer and use it in GitHub Desktop.
Unity script to add score
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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