38 lines
969 B
C#
38 lines
969 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class TriggerDoorController : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private Animator myDoor = null;
|
||
|
|
||
|
[SerializeField] private bool openTrigger = false;
|
||
|
[SerializeField] private bool closeTrigger = false;
|
||
|
|
||
|
[SerializeField] private string doorOpen = "DoorOpen";
|
||
|
[SerializeField] private string doorClose = "DoorClose";
|
||
|
|
||
|
// Start is called before the first frame update
|
||
|
|
||
|
public void OnTriggerEnter(Collider other)
|
||
|
{
|
||
|
if (other.CompareTag("Player"))
|
||
|
{
|
||
|
Debug.Log("col");
|
||
|
if (openTrigger)
|
||
|
{
|
||
|
Debug.Log("open");
|
||
|
myDoor.Play(doorOpen, 0, 0.0f);
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
else if (closeTrigger)
|
||
|
{
|
||
|
myDoor.Play(doorClose, 0, 0.0f);
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|