jretchy

Untitled

May 16th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1.  
  2.  
  3.     public GameObject shootCannon;
  4.     public PlayableDirector timeline;
  5.     public GameObject singleChar;
  6.  
  7.     public Camera laserCam;
  8.  
  9.     private void Start()
  10.     {
  11.         shootCannon.SetActive(false);
  12.         timeline.Stop();
  13.         laserCam.enabled = false;
  14.     }
  15.  
  16.     private void OnTriggerEnter(Collider other)
  17.     {
  18.         shootCannon.SetActive(true);
  19.     }
  20.  
  21.     private void OnTriggerExit(Collider other)
  22.     {
  23.         shootCannon.SetActive(false);
  24.     }
  25.  
  26.     private void Update()
  27.     {
  28.         if (shootCannon.activeInHierarchy == true && Input.GetKeyDown(KeyCode.E))
  29.         {
  30.             timeline.Play();
  31.             GetComponent<BoxCollider>().enabled = false;
  32.             shootCannon.SetActive(false);
  33.             StartCoroutine(LaserShooting());
  34.             singleChar.SetActive(false);
  35.         }
  36.     }
  37.  
  38.     IEnumerator LaserShooting()
  39.     {
  40.         laserCam.enabled = true;
  41.         GameObject.FindGameObjectWithTag("Player").GetComponent<CharacterController>().enabled = false;
  42.         GameObject.FindGameObjectWithTag("PlayerTwo").GetComponent<CharacterController>().enabled = false;
  43.         yield return new WaitForSeconds(0.60f);
  44.         FindObjectOfType<SoundController>().cannonFire.Play();
  45.         yield return new WaitForSeconds(0.45f);
  46.         FindObjectOfType<SoundController>().woodBreaking.Play();
  47.         yield return new WaitForSeconds(2f);
  48.         FindObjectOfType<SoundController>().cannonFire.Play();
  49.         yield return new WaitForSeconds(0.45f);
  50.         FindObjectOfType<SoundController>().woodBreaking.Play();
  51.         yield return new WaitForSeconds(1);
  52.         GameObject.FindGameObjectWithTag("Player").GetComponent<CharacterController>().enabled = true;
  53.         GameObject.FindGameObjectWithTag("PlayerTwo").GetComponent<CharacterController>().enabled = true;
  54.         laserCam.enabled = false;
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment