Advertisement
killerbng

Door Activator

Jan 5th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class DoorActivator : MonoBehaviour {
  5.  
  6.     public Animator[] lights;
  7.  
  8.     private Animator animator;
  9.  
  10.     void Awake () {
  11.         animator = GetComponent <Animator>();
  12.     }
  13.  
  14.     void OnTriggerEnter (Collider other) {
  15.         if (other.gameObject.tag == "Player") {
  16.             animator.SetBool ("Open", true);
  17.             foreach (var light in lights) {
  18.                 light.SetTrigger ("Activate");
  19.             }
  20.         }
  21.     }
  22.  
  23.     void OnTriggerExit (Collider other) {
  24.         if (other.gameObject.tag == "Player") {
  25.             animator.SetBool ("Open", false);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement