Programmer-DField 3b9e31a4b3 Added a safezone that reports the position of the player whenever they are within the area.
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.
2021-02-15 09:44:04 +00:00

47 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class SafeZone : MonoBehaviour
{
private GameObject player;
private bool isSafe = false;
public Vector3 respawnPoint;
public Vector3 playerPos;
public List<Vector3> lastPlayerPos = new List<Vector3>();
private void Start()
{
player = GameObject.Find("Player");
}
private void OnTriggerEnter(Collider other)
{
isSafe = true;
}
private void OnTriggerExit(Collider other)
{
isSafe = false;
}
private void FixedUpdate()
{
if (isSafe == true)
{
playerPos = player.transform.position;
lastPlayerPos.Add(playerPos);
respawnPoint = lastPlayerPos.Last();
Debug.Log("Player Position: X = " + playerPos.x + " --- Y = " + playerPos.y + " --- Z = " + playerPos.z + " --- RespawnPoint = " + respawnPoint);
}
}
public Vector3 safeSpawn()
{
return respawnPoint;
}
}