Files
LowPolyBattleSim/Library/PackageCache/com.unity.ai.navigation@c74b2724ed42/Samples~/Scripts/DestroyOnTrigger.cs

18 lines
434 B
C#
Raw Normal View History

2025-06-27 23:27:49 +01:00
using UnityEngine;
namespace Unity.AI.Navigation.Samples
{
/// <summary>
/// Destroy owning GameObject if any collider with a specific tag is trespassing
/// </summary>
public class DestroyOnTrigger : MonoBehaviour
{
public string m_Tag = "Player";
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == m_Tag)
Destroy(gameObject);
}
}
}