Не работает воспроизведение анимации при вхождении в триггер
Добавлено: 23 мар 2023, 21:59
Надо чтобы при вхождении в триггер радом со шлгабаумом шлагбаум открывался а при выходн закрывался, но просто скрипт не работает и все, вот скрипт
Синтаксис:
Используется csharp
using UnityEngine;
public class BarrierAnimation : MonoBehaviour
{
public GameObject ObjectWithAnim;
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
ObjectWithAnim.GetComponent<Animation>().Play();
}
}
public void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player")
{
ObjectWithAnim.GetComponent<Animation>().Play("Down");
}
}
}
public class BarrierAnimation : MonoBehaviour
{
public GameObject ObjectWithAnim;
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
ObjectWithAnim.GetComponent<Animation>().Play();
}
}
public void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player")
{
ObjectWithAnim.GetComponent<Animation>().Play("Down");
}
}
}