2025-11-25 19:42:40 +01:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class Destroyer : MonoBehaviour
|
|
|
|
|
{
|
2025-11-25 20:41:14 +01:00
|
|
|
[SerializeField]
|
|
|
|
|
private GameObject targetToDestroy;
|
|
|
|
|
|
2025-11-25 19:42:40 +01:00
|
|
|
// Destroy the GameObject this component is attached to
|
|
|
|
|
public void DestroySelf()
|
|
|
|
|
{
|
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
}
|
2025-11-25 20:41:14 +01:00
|
|
|
|
|
|
|
|
// Destroy the GameObject assigned in the inspector
|
|
|
|
|
public void DestroyTarget()
|
|
|
|
|
{
|
|
|
|
|
if (targetToDestroy == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning("Destroyer: No target assigned to destroy.", this);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Destroy(targetToDestroy);
|
|
|
|
|
}
|
2025-11-25 19:42:40 +01:00
|
|
|
}
|