csharp/1ZouLTReX1/FP-MOG/top%20down%20shooter/Assets/Scripts/FollowLocalPlayer.cs

FollowLocalPlayer.cs
using UnityEngine;

public clast FollowLocalPlayer : MonoBehaviour
{
    public Transform localPlayerTransform;
    public float smoothTime = 0.3F;
    private Vector3 velocity = Vector3.zero;

    void Update()
    {
        // Define a target position above and behind the target transform
        Vector3 targetPosition = localPlayerTransform.TransformPoint(new Vector3(0, 0, -10));

        // Smoothly move the camera towards that target position
        transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
    }
}