jretchy

Untitled

May 16th, 2021
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1.  
  2.     public GameObject pushButton;
  3.     public GameObject standardButton;
  4.     public GameObject pushedButton;
  5.  
  6.     public Animator anim;
  7.  
  8.     private void Start()
  9.     {
  10.         anim.enabled = true;
  11.  
  12.         pushButton.SetActive(false);
  13.         standardButton.SetActive(true);
  14.         pushedButton.SetActive(false);
  15.     }
  16.  
  17.     private void OnTriggerEnter(Collider other)
  18.     {
  19.         pushButton.SetActive(true);
  20.     }
  21.  
  22.     private void OnTriggerExit(Collider other)
  23.     {
  24.         pushButton.SetActive(false);
  25.     }
  26.  
  27.     private void Update()
  28.     {
  29.         if (pushButton.activeInHierarchy == true && Input.GetKeyDown(KeyCode.E))
  30.         {
  31.             anim.SetBool("ButtonPressed", true);
  32.             GetComponent<BoxCollider>().enabled = false;
  33.             standardButton.SetActive(false);
  34.             pushedButton.SetActive(true);
  35.             pushButton.SetActive(false);
  36.             FindObjectOfType<SoundController>().buttonPressed.Play();
  37.             FindObjectOfType<SoundController>().doorOpening.Play();
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment