Smooth camera follow in Unity. Often found in games, it adds a beautiful effect of moving the character with the help of Lerp.
Steps
- Create script SmoothCameraFollow.cs
using UnityEngine;
public class SmoothCameraFollow : MonoBehaviour
{
[SerializeField] private float _smoothSpeed = 0.1f;
[SerializeField] private Transform _target;
private Vector3 _offset;
private void Start()
{
_offset = transform.position;
}
private void FixedUpdate()
{
transform.position = Vector3.Slerp(transform.position, _target.position + _offset, _smoothSpeed);
}
}
- Add script to the Main Camera.