How to Make Smooth Camera Follow in Unity – Unity By Example

How to Make Smooth Camera Follow in Unity

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.

Result

Download

5 2 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments