33 lines
840 B
C#
33 lines
840 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Ktyl.Util;
|
|
|
|
public class PlayerDeath : MonoBehaviour
|
|
{
|
|
[SerializeField] private SerialVector3 _respawnPosition;
|
|
[SerializeField] private GameEvent _playerDeath;
|
|
[SerializeField] private GameEvent _playerRespawn;
|
|
|
|
public void Respawn()
|
|
{
|
|
StartCoroutine(RespawnPlayerCR());
|
|
}
|
|
|
|
// raise death/respawn events with a given intermediate delay
|
|
public IEnumerator RespawnPlayerCR()
|
|
{
|
|
_playerDeath.Raise();
|
|
|
|
yield return new WaitForSeconds(1.5f);
|
|
|
|
// move player to respawn position
|
|
transform.position = _respawnPosition;
|
|
|
|
// need to wait a bit for the respawn to actually work?? >:v
|
|
yield return new WaitForSeconds(0.5f);
|
|
|
|
_playerRespawn.Raise();
|
|
}
|
|
}
|