neon_run/Assets/Scripts/CollisionDetector.cs
2025-11-13 22:37:47 +05:30

30 lines
663 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class CollisionDetector : MonoBehaviour
{
public List<string> tagsToDetect;
public Action<Collider> OnEnter;
public Action<Collider> OnExit;
private void OnTriggerEnter(Collider other)
{
if(tagsToDetect.Contains(other.tag) || tagsToDetect.Count == 0)
{
OnEnter?.Invoke(other);
}
}
private void OnTriggerExit(Collider other)
{
if(tagsToDetect.Contains(other.tag) || tagsToDetect.Count == 0)
{
OnExit?.Invoke(other);
}
}
}