I’m just getting used to Cinemachine and I’m really liking it! Setting up following dolly shots is pretty intuitive but I’m really struggling with something as simple as setting up a “continually orbit around this target” shot that’s not based off of a player’s input. Nothing’s really stopping me from making a simple rotation script to do it but I really like cinemachine’s semi-code-free approach to cameras and would prefer some way to do this within the inspector.
I have a virtual camera with an Orbital Transposer. I don’t want to map to a mouse input so I removed the input axis name but I do want to lerp the value with a speed. Is there something I’m just missing or do I need to write my own script to handle this?
Previously I’ve set up circular looped smooth path with a dolly cart but that’s a bit too cumbersome to set up. An orbital transposer looks like exactly what I want, it’s just unclear how to set it up so that it orbits automatically?
This is the current script I’m using. I attach this to the virtual camera and set my speed to whatever. This method works fine, would just be nice not having to do this step manually (Scripting isn’t my forte)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class FilmOrbit : MonoBehaviour
{
public float speed = 10f;
private Cinemachine.CinemachineVirtualCamera m_VirtualCam;
void Start(){
if(GetComponent<Cinemachine.CinemachineVirtualCamera>())
m_VirtualCam = GetComponent<Cinemachine.CinemachineVirtualCamera>();
}
void Update()
{
if(m_VirtualCam.GetCinemachineComponent<CinemachineOrbitalTransposer>())
m_VirtualCam.GetCinemachineComponent<CinemachineOrbitalTransposer>().m_XAxis.Value += Time.deltaTime * speed;
}
}
You’re asking for a specialty thing, so you’re stuck doing a little scripting. Your solution is just what I would have suggested, only I would modify it slightly for safety and performance, as follows:
using UnityEngine;
using Cinemachine;
public class FilmOrbit : MonoBehaviour
{
public float speed = 10f;
private CinemachineOrbitalTransposer m_orbital;
void Start()
{
var vcam = GetComponent<CinemachineVirtualCamera>();
if (vcam != null)
m_orbital = vcam.GetCinemachineComponent<CinemachineOrbitalTransposer>();
}
void Update()
{
if (m_orbital != null)
m_orbital.m_XAxis.Value += Time.deltaTime * speed;
}
}
2 Likes
How can I incorporate the mouse Y Orbit into this as well? Trying to make this work on both Axes. Thank you so kindly!
You can use a vcam with FramingTransposer in Body and DoNothing in Aim. Set the Follow target to be the thing you want the camera to orbit around. To make the camera orbit in any direction, your script needs to modify vcam.transform.rotation. Try it by hand in the inspector to get an understanding of how it works.