added comments and organized project files
This commit is contained in:
27
Assets/Scripts/Game/RespawnOnTriggerEnter.cs
Normal file
27
Assets/Scripts/Game/RespawnOnTriggerEnter.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class RespawnOnTriggerEnter : MonoBehaviour
|
||||
{
|
||||
public Vector2 spawnPoint;
|
||||
public bool spawnPointIsInitialPosition = false;
|
||||
public string respawnTag;
|
||||
|
||||
private void Start() // Set the spawn point to the initial maps spawn point
|
||||
{
|
||||
if (spawnPointIsInitialPosition)
|
||||
{
|
||||
spawnPoint = transform.position;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.CompareTag(respawnTag))
|
||||
{
|
||||
if (TryGetComponent(out Damageable damageable))
|
||||
{
|
||||
damageable.Damage(9999f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user