Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class weaponpurchase : MonoBehaviour {
  6.  
  7.     public GameObject weaponToActivate;
  8.     public GameObject weaponToDeActivate;
  9.     public bool abletoPurchase = false;
  10.     public int weaponcost;
  11.  
  12.     public void OnTriggerEnter(Collider other)
  13.     {
  14.         weaponToDeActivate = GameObject.FindGameObjectWithTag("currentweapon");
  15.         abletoPurchase = true;
  16.  
  17.        
  18.     }
  19.  
  20.     public void OnTriggerExit(Collider other)
  21.     {
  22.         abletoPurchase = false;
  23.         weaponToDeActivate = null;
  24.     }
  25.     void Update ()
  26.     {
  27.         if (abletoPurchase == true && Input.GetButtonDown("Activate"))
  28.         {
  29.             weaponToDeActivate.SetActive(false);
  30.             weaponToActivate.SetActive(true);
  31.            
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement