47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class TriggerDoorController : MonoBehaviour
|
|
{
|
|
[SerializeField] private Animator myDoor = null;
|
|
|
|
[SerializeField] private bool Trigger = 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 (Trigger)
|
|
{
|
|
Debug.Log("open");
|
|
myDoor.Play(doorOpen, 0, 0.0f);
|
|
}
|
|
|
|
/*else if (closeTrigger)
|
|
{
|
|
myDoor.Play(doorClose, 0, 0.0f);
|
|
}*/
|
|
}
|
|
}
|
|
|
|
public void OnTriggerExit(Collider other)
|
|
{
|
|
if (other.CompareTag("Player"))
|
|
{
|
|
if (Trigger)
|
|
{
|
|
myDoor.Play(doorClose, 0, 0.0f);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|