dronkowitz

Cannon.cs

May 24th, 2021 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Cannon : MonoBehaviour
  6. {
  7. GameObject source;
  8. public AudioClip clip;
  9. public bool cannon1Activated = false;
  10.  
  11. // Start is called before the first frame update
  12. void Start()
  13. {
  14.  
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update()
  19. {
  20.  
  21. }
  22.  
  23. private void OnTriggerEnter(Collider other)
  24. {
  25. if (cannon1Activated == false)
  26. {
  27. NewPlayerMovement player = other.GetComponent<NewPlayerMovement>();
  28.  
  29. if (player && cannon1Activated == false)
  30. {
  31. cannon1Activated = true;
  32. source = Resources.Load<GameObject>("Audio Object");
  33. GameObject ao = Instantiate(source, transform.position, Quaternion.identity);
  34. ao.GetComponent<AudioObject>().Setup(clip, transform);
  35. }
  36. }
  37.  
  38. }
  39. }
  40.  
Add Comment
Please, Sign In to add comment