2025-01-15 14:07:17 -05:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class RespawnOnTriggerEnter : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Vector2 spawnPoint;
|
|
|
|
|
public bool spawnPointIsInitialPosition = false;
|
|
|
|
|
public string respawnTag;
|
|
|
|
|
|
2025-03-28 17:39:07 -04:00
|
|
|
private void Start() // Set the spawn point to the initial maps spawn point
|
2025-01-15 14:07:17 -05:00
|
|
|
{
|
|
|
|
|
if (spawnPointIsInitialPosition)
|
|
|
|
|
{
|
|
|
|
|
spawnPoint = transform.position;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D other)
|
|
|
|
|
{
|
|
|
|
|
if (other.CompareTag(respawnTag))
|
|
|
|
|
{
|
2025-03-07 10:03:16 -05:00
|
|
|
if (TryGetComponent(out Damageable damageable))
|
|
|
|
|
{
|
2025-04-16 19:20:36 -04:00
|
|
|
print("Voided out " + other.name);
|
2025-03-07 10:03:16 -05:00
|
|
|
damageable.Damage(9999f);
|
|
|
|
|
}
|
2025-01-15 14:07:17 -05:00
|
|
|
}
|
|
|
|
|
}
|
2025-03-06 01:27:42 -05:00
|
|
|
}
|