19 lines
384 B
C#
19 lines
384 B
C#
using UnityEngine;
|
|
|
|
public class CameraFollow : MonoBehaviour
|
|
{
|
|
public Transform target;
|
|
|
|
public Vector3 offset;
|
|
|
|
public float SmoothSpeed = 1f;
|
|
|
|
private void Update()
|
|
{
|
|
Vector3 b = target.position + offset;
|
|
Vector3 position = Vector3.Lerp(base.transform.position, b, SmoothSpeed * Time.deltaTime);
|
|
base.transform.position = position;
|
|
base.transform.LookAt(target);
|
|
}
|
|
}
|