Smooth Camera Follow Unity 2D – In this quick and easy tutorial, discover how to implement a smooth camera follow system for your 2D games. Learn step-by-step how to keep your camera perfectly aligned with your player character, ensuring a seamless and polished gameplay experience. Perfect for enhancing your game’s visuals and player immersion, this guide will help you create fluid camera movements that adapt to your player’s actions. Watch now and take your 2D game to the next level!Â
Camera Follow Character 2D Unity Script
using UnityEngine;
public class SmoothCamera : MonoBehaviour
{
private Vector3 offset = new Vector3(0f, 0f, -10f);
private float smoothTime = 0.25f;
private Vector3 velocity = Vector3.zero;
[SerializeField] private Transform target;
private void Update()
{
Vector3 targetPosition = target.position + offset;
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
}
}