2026-07-19 19:37:17 +03:00
|
|
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2026-08-18 01:15:31 +03:00
|
|
|
|
2026-07-19 19:37:17 +03:00
|
|
|
|
|
|
|
|
public class CameraFollow : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Transform target;
|
|
|
|
|
|
|
|
|
|
private Vector3 _offset;
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
if (target != null)
|
|
|
|
|
{
|
|
|
|
|
_offset = transform.position - target.position;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("Камера: не назначен объект Target!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LateUpdate()
|
|
|
|
|
{
|
|
|
|
|
if (target != null)
|
|
|
|
|
{
|
|
|
|
|
transform.position = target.position + _offset;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|