Hi, is there any way anyone can help me with this situation?
When the player falls into the “void” the player dies. However, the camera follows with him.
here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
public GameObject player;
private Vector3 offset;
public bool gameOver;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.position = player.transform.position + offset + new Vector3(5, 5, -15);
if (gameOver == true)
{
transform.position = new Vector3(0, 0, 0);
}
if (gameOver == false)
{
transform.position = player.transform.position + offset + new Vector3(5, 5, -15);
}
}
}
Please help if you can. Thanks.