You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FlyingFred/Assets/CameraFollow.cs

16 lines
455 B
C#

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);
}
}
}