You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/D2D_Scripts/Gameplay/DoActionOnPlayerEnter.cs

28 lines
631 B
C#

using D2D.Gameplay;
using D2D.Utilities;
using D2D.Utils;
using UltEvents;
using UnityEngine;
namespace D2D
{
public class DoActionOnPlayerEnter : MonoBehaviour
{
[SerializeField] private UltEvent _action;
[SerializeField] private bool _once = true;
private int _playerEntersCount;
private void OnTriggerEnter(Collider other)
{
if (other.Is<Player>())
{
if (_once && _playerEntersCount > 0)
return;
_playerEntersCount++;
_action?.Invoke();
}
}
}
}