The player is moving on a planar surface, which it can fall off.
I would like to make my camera follow the player, on x and z axis, but on y axis, it should stay at one “level” for example; at y = 2. And when the player falls down from the map and reaches y = 0.8, the camera should rotate down to keep it in frame.
using UnityEngine;
public class FollowPlayer : MonoBehaviour
{
public Transform player;
public Vector3 offset; //It's 0, 2.5, -5
void Update()
{
transform.position = new Vector3(player.position.x + offset.x, offset.y, player.position.z + offset.z);
}
What should I add to this, to make it happen?
This currently only makes the camera follow the player without moving on y axis.