Advertisement
Guest User

Untitled

a guest
Feb 26th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TriggerEvent : MonoBehaviour
  6. {
  7. public GameObject lightBulb = null;
  8. public GameObject wall = null;
  9. public AudioClip lightBulbOn = null;
  10.  
  11. void OnTriggerEnter ( Collider other )
  12. {
  13. if (other.name == "player")
  14. {
  15. // turn on light bulb
  16. lightBulb.SetActive (true);
  17.  
  18. audio.PlayOneShot(lightBulbOn);
  19.  
  20. wall.GetComponent<ObjectScaling>().EnableScale();
  21. wall.GetComponent<ObjectColor>().EnableColor();
  22.  
  23. Debug.Log ("LightBulb turned on");
  24. }
  25. }
  26.  
  27. void OnTriggerExit (Collider other)
  28. {
  29. if (other.name == "player")
  30. {
  31. // Turn off light bulb
  32. lightBulb.SetActive (false);
  33.  
  34. audio.Stop ();
  35.  
  36. wall.GetComponent<ObjectScaling>().DisableScale();
  37. wall.GetComponent<ObjectColor>().DisableColor();
  38.  
  39. Debug.Log ("LightBulb turned off");
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement