Added a deathzone that plays a death animation on trigger, fades the screen, respawns the player at the last known safe position and the fades the screen back in. Added scripts for safezone and deathzone. Added some make do animations and animators. Added some materials for testing purposes.
41 lines
934 B
C#
41 lines
934 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DeathZone : MonoBehaviour
|
|
{
|
|
public SafeZone sz;
|
|
public Animator animator;
|
|
|
|
public GameObject fadeScreen;
|
|
|
|
[SerializeField] private Transform player;
|
|
private bool isDead;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
isDead = true;
|
|
|
|
if (isDead == true)
|
|
{
|
|
|
|
StartCoroutine(respawnPlayer());
|
|
}
|
|
}
|
|
|
|
IEnumerator respawnPlayer()
|
|
{
|
|
animator.SetTrigger("IsDead");
|
|
yield return new WaitForSeconds(2);
|
|
|
|
fadeScreen.GetComponent<Animation>().Play("fadeAnim");
|
|
//yield return new WaitForSeconds(0.5f);
|
|
|
|
player.transform.position = sz.safeSpawn();
|
|
yield return new WaitForSeconds(2);
|
|
|
|
fadeScreen.GetComponent<Animation>().Play("fadeInAnim");
|
|
yield return null;
|
|
isDead = false;
|
|
}
|
|
} |