Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class NPC : MonoBehaviour {
  7.  
  8.     public GameObject npcUI;
  9.     public PlayerManager playerManager;
  10.  
  11.     void Start () {
  12.         npcUI.SetActive(false);
  13.     }
  14.    
  15.     void Update () {
  16.        
  17.     }
  18.     public void OnTriggerEnter2D(Collider2D other)
  19.     {
  20.         if(other.gameObject.tag == "Player")
  21.         {
  22.             npcUI.SetActive(true);
  23.         }
  24.  
  25.     }
  26.     public void OnTriggerExit2D(Collider2D collision)
  27.     {
  28.  
  29.         if (collision.gameObject.tag == "Player")
  30.         {
  31.             npcUI.SetActive(false);
  32.         }
  33.     }
  34.     public void buySpeed()
  35.     {
  36.         playerManager.speed += 1;
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement