using System; using UnityEngine; public class OpenDoor : MonoBehaviour { [SerializeField] private Animator myDoor = null; [SerializeField] public bool openTrigger = false; [SerializeField] private string animationFile = "DoorAnimation.013"; private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")){ Debug.Log("Player has entered the trigger I am: " + gameObject.name); if (!openTrigger){ // check that the animation is the same as the myDoor if (myDoor == null){ Debug.LogError("myDoor is null"); return; } if (string.IsNullOrEmpty(animationFile)){ Debug.LogError("animationFile is null or empty"); return; } Debug.Log("Playing animation: " + animationFile); myDoor.Play(animationFile, 0, 0.0f); gameObject.SetActive(false); } } } }