Загрузка данных


using UnityEngine;

public class CameraFollow : MonoBehaviour
{
    public Transform target;      // Наша белка
    public float smoothSpeedX = 0.125f; // Плавность по горизонтали (быстрая)
    public float smoothSpeedY = 0.05f;  // Плавность по вертикали (очень медленная!)
    public Vector3 offset;        // Смещение камеры

    void LateUpdate()
    {
        if (target != null)
        {
            // 1. Считаем идеальную позицию, где должна быть камера
            float desiredX = target.position.x + offset.x;
            float desiredY = target.position.y + offset.y;

            // 2. Плавно двигаем по оси X (как и раньше)
            float nextX = Mathf.Lerp(transform.position.x, desiredX, smoothSpeedX);

            // 3. Плавно двигаем по оси Y (но с меньшей скоростью, чтобы сгладить прыжки!)
            float nextY = Mathf.Lerp(transform.position.y, desiredY, smoothSpeedY);

            // 4. Применяем новые координаты к камере
            transform.position = new Vector3(nextX, nextY, offset.z);
        }
    }
}