31 lines
552 B
C#
31 lines
552 B
C#
|
|
using UnityEngine;
|
|
|
|
using UnityEngine;
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |