wuxianshengcong/Library/PackageCache/com.unity.ai.navigation@1.1.5/Samples~/Scripts/DestroyOnTrigger.cs
2025-01-02 14:50:41 +08:00

18 lines
434 B
C#

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);
}
}
}