I’ve tried toggling the CinemachineFreeLook object on and off, and even tried editing the script itself to check the mouse button in an if statement any time it messes with the Transform. Nothing seems to work.
I just want the camera to orbit when the player right-clicks and drags, instead of anytime the player moves the mouse. At all other times, I want the mouse to just be a normal mouse cursor that doesn’t affect the camera at all. I just want a simple on-mouse-down orbital camera. Not an always-on orbital camera.
By default the FreeLook queries the input manager for MouseX and Mouse Y and responds to that. You can intercept this call and return 0 unless the mouse button is down.
See CinemachineCore.GetInputAxis. Override that with your custom delegate.
Excellent!
May I suggest that instead of returning 0 on the last line, you do return UnityEngine.Input.GetAxis(axisName);
That way you’re not messing up all the other input channels.
The way to do that would be to make a custom script component alongside the FreeLook that looks at the mousewheel input and scales the radii in the FreeLook’s orbits.
I wanted to cache the orbits in my GameManager script so I could multiply their default settings by a zoom level, rather than explicitly defining them each by hand, but I ran into a snag:
public Orbit[] m_Orbits;
…gives me…
…but I can’t figure out what to Include. (The Orbit struct is defined locally in CinemachineFreeLook.cs.)
it works, script needs to go on the camera the one where the cinemachine brain script is located.
if you have the “Simple Camera Controller Script” enabled you need to disable it. That script will interfere with pretty much anything that want to control the camera.
Normally, putting that script on the main camera (or on any other active object) will work. Possibly you have some other scripts or settings that are interfering. Try it on a fresh project, or on one of the CM sample scenes.