Guest User

Untitled

a guest
Mar 13th, 2024
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using UnityEngine;
  2. using Cinemachine;
  3.  
  4. /*
  5.     Quick and rough prototype script to make the
  6.     CinemachineOrbitalCamera rotate around the target.
  7.     ⚠️ Not sure if that's the best way to do it tho.
  8.  
  9.     Please consider subscribing to my Unity tutorial channel:
  10.     https://www.youtube.com/@AnzyYoutube
  11. */
  12. public class FilmOrbit : MonoBehaviour
  13. {
  14.     [SerializeField]
  15.     private float speed = 10f;
  16.  
  17.     private CinemachineOrbitalTransposer _orbitalCamera;
  18.     private float _position;
  19.  
  20.     void Start()
  21.     {
  22.         var vcam = GetComponent<CinemachineVirtualCamera>();
  23.         if (vcam != null)
  24.             _orbitalCamera = vcam.GetCinemachineComponent<CinemachineOrbitalTransposer>();
  25.     }
  26.  
  27.     void Update()
  28.     {
  29.         _position += (Time.deltaTime * speed) % 360;
  30.         _orbitalCamera.m_XAxis.Value = _position;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment