using UnityEngine; namespace GrassCutter { /// Slow cinematic drift around the ocean rig while in the main menu. Gives the camera to the local player in game. public class MenuCamera : MonoBehaviour { static MenuCamera _i; public Transform cam; public Vector3 focus = new Vector3(0f, 2.5f, 0f); public float radius = 22f, height = 7f, speed = 0.02f; bool _active = true; float _t; void Awake() { _i = this; if (!cam && Camera.main) cam = Camera.main.transform; } public static void Release() { if (_i) _i._active = false; } public static void Reclaim() { if (!_i || !_i.cam) return; _i._active = true; _i.cam.SetParent(_i.transform, false); CameraFx.FovTarget(0f); } void LateUpdate() { if (!_active || !cam) return; _t += Time.unscaledDeltaTime * speed; float a = _t * Mathf.PI * 2f; var pos = focus + new Vector3(Mathf.Cos(a) * radius, height + Mathf.Sin(a * 2f) * 0.6f, Mathf.Sin(a) * radius * 0.75f); cam.position = pos; cam.rotation = Quaternion.LookRotation(focus + new Vector3(Mathf.Sin(a * 0.7f) * 1.5f, 0, 0) - pos, Vector3.up); } } }