using UnityEngine;

namespace SpawnCampGames.Cameras
{
    public class CameraBob : MonoBehaviour
    {
        [Header("Bob Settings")]
        [SerializeField] private float bobDistance = 0.25f;   // How far up/down the camera moves
        [SerializeField] private float bobSpeed = 2f;        // Speed of bobbing

        private Vector3 startLocalPos;

        void Start()
        {
            // Store the starting local position of the camera
            startLocalPos = transform.localPosition;
        }

        void Update()
        {
            BobCamera();
        }

        private void BobCamera()
        {
            // Calculate offset using sine wave for smooth bobbing
            float yOffset = Mathf.Sin(Time.time * bobSpeed) * bobDistance;

            // Apply local Y offset
            transform.localPosition = startLocalPos + new Vector3(0f, yOffset, 0f);
        }
    }
}