using UnityEngine; public class CameraFollow : MonoBehaviour { public Transform target; // Reference to the character public float smoothSpeed = 0.125f; void LateUpdate() { if (target != null) { Vector3 targetPosition = new Vector3(transform.position.x, target.position.y, transform.position.z); transform.position = Vector3.Lerp(transform.position, targetPosition, smoothSpeed); } } }