Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TriggerEvent : MonoBehaviour
- {
- public GameObject lightBulb = null;
- public GameObject wall = null;
- public AudioSource lightBulbOnAS = null;
- public AudioClip lightBulbOn = null;
- void OnTriggerEnter ( Collider other )
- {
- if (other.name == "player")
- {
- // turn on light bulb
- lightBulb.SetActive (true);
- if (lightBulbOnAS == null)
- lightBulbOnAS = GetComponent<AudioSource>();
- lightBulbOnAS.PlayOneShot(lightBulbOn);
- //audio.PlayOneShot(lightBulbOn);
- wall.GetComponent<ObjectScaling>().EnableScale();
- wall.GetComponent<ObjectColor>().EnableColor();
- Debug.Log ("LightBulb turned on");
- }
- }
- void OnTriggerExit (Collider other)
- {
- if (other.name == "player")
- {
- // Turn off light bulb
- lightBulb.SetActive (false);
- lightBulbOnAS.Stop ();
- wall.GetComponent<ObjectScaling>().DisableScale();
- wall.GetComponent<ObjectColor>().DisableColor();
- Debug.Log ("LightBulb turned off");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement