using System.Collections; using System.Collections.Generic; using UnityEngine; public class DeathZone : MonoBehaviour { public Animator animator; public GameObject fadeScreen; private GameObject player; [SerializeField] private RespawnManager respawnManager; private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Player") { player = other.gameObject; StartCoroutine(respawnPlayer()); } } IEnumerator respawnPlayer() { animator.SetTrigger("IsDead"); yield return new WaitForSeconds(2); fadeScreen.GetComponent().Play("fadeAnim"); //yield return new WaitForSeconds(0.5f); player.transform.position = respawnManager.getRespawnPoint(); yield return new WaitForSeconds(2); fadeScreen.GetComponent().Play("fadeInAnim"); yield return null; } }