Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- //Player Script
- public class PlayerScript : MonoBehaviour {
- public int score = 0; //how many boxes have we found already
- public Text ScoreText; //our scorebar
- void Start () {
- }
- void Update () {
- ScoreText.text = "Score: " + score;
- }
- void OnTriggerEnter(Collider other) //if we found a box
- {
- if (other.gameObject.CompareTag("PickUp")) //check whether the object is a box
- {
- Destroy(other.gameObject);
- score++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement