21 lines
556 B
C#
21 lines
556 B
C#
using UnityEngine;
|
|
|
|
public class ChaseCameraController : MonoBehaviour
|
|
{
|
|
public Transform player; // Reference to the player
|
|
public Vector3 offset = new Vector3(0, 2, 5); // Offset in front of the player
|
|
|
|
public float followSpeed = 5f;
|
|
|
|
void LateUpdate()
|
|
{
|
|
if (player == null) return;
|
|
|
|
Vector3 targetPos = player.position + offset;
|
|
transform.position = Vector3.Lerp( transform.position, targetPos, followSpeed * Time.deltaTime);
|
|
|
|
// transform.LookAt(player.position + Vector3.up * 1.5f);
|
|
}
|
|
|
|
}
|