Podążanie kamery za graczem Unity
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
[SerializeField] Transform target;
Vector3 offset;
Vector3 tempPos;
void Start()
{
if (target != null)
{
offset = transform.position - target.position;
}
}
void LateUpdate()
{
if (target != null)
{
tempPos = target.position + offset;
tempPos.y = 0f;
transform.position = tempPos;
}
}
}