StellarXipher/Assets/Scripts/OpenDoor.cs
EthanPisani 7d1aaa992f
All checks were successful
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Successful in 4m46s
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Successful in 4m32s
Build project / Publish to itch.io (StandaloneLinux64) (push) Successful in 5s
Build project / Publish to itch.io (StandaloneWindows64) (push) Successful in 6s
added - door animations - emergency lights, lever, sounds - amibent sounds
2025-03-15 00:16:15 -04:00

34 lines
1.0 KiB
C#

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);
}
}
}
}