2026-02-04 11:43:12 +00:00
|
|
|
using System.Collections;
|
2026-02-02 12:33:32 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class CameraEffect : MonoBehaviour
|
|
|
|
|
{
|
2026-02-04 11:43:12 +00:00
|
|
|
private Transform target;
|
2026-02-02 12:33:32 +00:00
|
|
|
|
|
|
|
|
public float smoothTime = 0.3f;
|
|
|
|
|
public Vector3 offset = new Vector3(0, 0, -10f);
|
|
|
|
|
private Vector3 _velocity = Vector3.zero;
|
2026-02-04 11:43:12 +00:00
|
|
|
|
|
|
|
|
private void Update()
|
2026-02-02 12:33:32 +00:00
|
|
|
{
|
|
|
|
|
if (target == null)
|
|
|
|
|
{
|
|
|
|
|
target = GameObject.FindGameObjectWithTag("Player")?.transform;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vector3 targetPosition = target.position + offset;
|
|
|
|
|
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _velocity, smoothTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|