first commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Smooth top/back camera that keeps the player and generated path visible.
|
||||
/// </summary>
|
||||
public class CameraFollow : MonoBehaviour
|
||||
{
|
||||
public Transform target;
|
||||
public Vector3 offset = new Vector3(0f, 8f, -8f);
|
||||
public float followSpeed = 6f;
|
||||
public float lookHeight = 1f;
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 desiredPosition = target.position + offset;
|
||||
transform.position = Vector3.Lerp(transform.position, desiredPosition, followSpeed * Time.deltaTime);
|
||||
transform.LookAt(target.position + Vector3.up * lookHeight);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user