AMJV_UNITY/TP3/Assets/Scripts/CameraThings/FollowTarget.cs
2024-12-10 13:14:30 +01:00

23 lines
548 B
C#

using UnityEngine;
public class FollowTarget : MonoBehaviour
{
[SerializeField] Transform target;
[SerializeField]
[Range(0f, 1f)]
float lerpSpeed;
Vector3 offset;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
offset = transform.position - target.position;
}
// Update is called once per frame
void FixedUpdate()
{
transform.position = Vector3.Lerp(transform.position, target.position + offset, lerpSpeed);
}
}