Advertisement
rengetsu

PD_PlayerScript

Apr 13th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. //Player Script
  6. public class PlayerScript : MonoBehaviour {
  7.     public int score = 0; //how many boxes have we found already
  8.     public Text ScoreText; //our scorebar
  9.  
  10.     void Start () {
  11.     }
  12.     void Update () {
  13.         ScoreText.text = "Score: " + score;
  14.     }
  15.     void OnTriggerEnter(Collider other) //if we found a box
  16.     {
  17.         if (other.gameObject.CompareTag("PickUp")) //check whether the object is a box
  18.         {
  19.             Destroy(other.gameObject);
  20.             score++;
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement