My Vector3.Lerp() smooth follow camera

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CamFollow : MonoBehaviour
{
	[SerializeField]Transform playerPrefab;
	[Header("Camera Settings")]
	[Space(1.5f)]
	[SerializeField]Vector3 originalDist = new Vector3 (24.72f, 24.72f, -12.66f);
	[Space(5)]
	[SerializeField]float dampCam = 0.005f;
	
	// Update is called once per frame
	void LateUpdate ()
	{
		Following ();
	}

	//smooth following
	void Following()
	{
		Vector3 toPos = playerPrefab.position + (playerPrefab.rotation * originalDist);//vector3 to indicate player position

		transform.position = Vector3.Lerp (transform.position, toPos, dampCam);//interpolate enter camp position and toPos position with a little bit os damp (0.005f is to mutch)
		transform.LookAt (playerPrefab, playerPrefab.up);//reference were is up

	}

/* my Ben Tristan Version
    [SerializeField]Transform playerPrefab;  	

    void LateUpdate()
{
	transform.position = playerPrefab.position;
}
*/
   }

Privacy & Terms