21 lines
526 B
C#
21 lines
526 B
C#
using UnityEngine;
|
|
|
|
public class CameraFollow : MonoBehaviour
|
|
{
|
|
public Transform target;
|
|
public Vector3 offset = new Vector3(0f, 8f, -7f);
|
|
public float followSpeed = 8f;
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (target == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Vector3 desiredPosition = target.position + offset;
|
|
transform.position = Vector3.Lerp(transform.position, desiredPosition, followSpeed * Time.deltaTime);
|
|
transform.rotation = Quaternion.Euler(58f, 0f, 0f);
|
|
}
|
|
}
|