Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public GameObject pushButton;
- public GameObject standardButton;
- public GameObject pushedButton;
- public Animator anim;
- private void Start()
- {
- anim.enabled = true;
- pushButton.SetActive(false);
- standardButton.SetActive(true);
- pushedButton.SetActive(false);
- }
- private void OnTriggerEnter(Collider other)
- {
- pushButton.SetActive(true);
- }
- private void OnTriggerExit(Collider other)
- {
- pushButton.SetActive(false);
- }
- private void Update()
- {
- if (pushButton.activeInHierarchy == true && Input.GetKeyDown(KeyCode.E))
- {
- anim.SetBool("ButtonPressed", true);
- GetComponent<BoxCollider>().enabled = false;
- standardButton.SetActive(false);
- pushedButton.SetActive(true);
- pushButton.SetActive(false);
- FindObjectOfType<SoundController>().buttonPressed.Play();
- FindObjectOfType<SoundController>().doorOpening.Play();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment