public class PlayerDeath : MonoBehaviour
{
private bool hasEntered;
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Enemy") && !hasEntered)
{
Destroy(gameObject);
LevelManager.instance.Respawn();
}
}
}
public class LevelManager : MonoBehaviour
{
public static LevelManager instance;
public Transform respawnPoint;
public GameObject playerPrefab;
private void Awake()
{
instance = this;
}
public void Respawn()
{
GameObject player = Instantiate(playerPrefab, respawnPoint.position, Quaternion.identity);
}
}