Files
EmeraidAI/~Samples/Demo/Demo Source/Scripts/SmoothFollow.cs
2025-07-20 10:01:29 +08:00

19 lines
552 B
C#

using UnityEngine;
using System.Collections;
namespace EmeraldAI.CharacterController
{
public class SmoothFollow : MonoBehaviour
{
public Vector3 CameraOffset;
public Transform target;
public float smoothTime = 0.3F;
private Vector3 velocity = Vector3.zero;
void Update()
{
// Smoothly move the camera towards that target position
transform.position = Vector3.SmoothDamp(transform.position, target.position + CameraOffset, ref velocity, smoothTime);
}
}
}