killerbng icon

Door Activator

killerbng | PRO | 01/06/17 01:05:38 AM UTC | 0 ⭐ | 296 👁️ | Never ⏰ | []
C# |

650 B

|

None

|

0 👍

/

0 👎

using UnityEngine;
using System.Collections;
 
public class DoorActivator : MonoBehaviour {
 
    public Animator[] lights; 
 
    private Animator animator;
 
    void Awake () {
        animator = GetComponent <Animator>();
    }
 
    void OnTriggerEnter (Collider other) {
        if (other.gameObject.tag == "Player") {
            animator.SetBool ("Open", true);
            foreach (var light in lights) {
                light.SetTrigger ("Activate");
            }
        }
    }
 
    void OnTriggerExit (Collider other) {
        if (other.gameObject.tag == "Player") {
            animator.SetBool ("Open", false);
        }
    }
}

Comments