StellarXipher/Assets/DoorAnim/TriggerDoorController.cs

26 lines
722 B
C#

using UnityEngine;
public class NewMonoBehaviourScript : MonoBehaviour
{
[SerializeField] private Animator myDoor = null;
[SerializeField] private bool requiresLightSwitchActivation = true;
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player") &&
(!requiresLightSwitchActivation || LightSwitchManager.IsLightSwitchActivated))
{
myDoor.Play("DoorOpen", 0, 0.0f);
}
}
private void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player") &&
(!requiresLightSwitchActivation || LightSwitchManager.IsLightSwitchActivated))
{
myDoor.Play("DoorClose", 0, 0.0f);
}
}
}