鏡頭圍繞目標旋轉
© 2025 魔力結構 未經授權,請勿任意轉載、改作或商業使用,僅供個人學習參考用途 using UnityEngine; public class GarageOrbitCamera : MonoBehaviour { public Transform target; public float distance = 15f; public float zoomSpeed = 2f; public float minDistance = 5f; public float maxDistance = 25f; public float rotationSpeed = 5f; public float verticalLimit = 80f; [Header("自動旋轉設定")] public float idleTimeThreshold = 5f; public float autoYawSpeed = 10f; public float autoPitchAmplitude = 5f; public float autoPitchMin = 10f; public float autoPitchMax = 25f; public float autoPitchSpeed = 0.5f; // sin 波速度 private float yaw = 90f; private float pitch = 20f; private float targetPitch; private float targetDistance; private float idleTimer = 0f; private float autoPitchTimer = 0f; private Vector3 currentPos; private Vector2 lastMousePos; private bool isDragging = false; void Start() { targetPitch = pitch; ...