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

25 lines
719 B
C#

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