Hello all,
I have a question, I’m trying to figure out how to add rotation to a virtual camera.
since cinemachine controls the rotation… is there an extension similar to offset, but for rotation?
Hello all,
I have a question, I’m trying to figure out how to add rotation to a virtual camera.
since cinemachine controls the rotation… is there an extension similar to offset, but for rotation?
Not out of the box, no, but you can take CinemachineCameraOffset.cs, copy it, and modify it to affect state.OrientationCorrection instead of state.PositionCorrection. The units are in camera-local space.
Thanks! you helped me a lot!
here’s a quick summery if anyone needs:
Thanks rubiez64 - I was totally happy when I found your post after hours of trying to get some rotation offset to my virtual camera!
I would like to recommend to add a script like that to the official cinemachine package. There might be other users who really need it.
Hey guys, I know it’s old but the problem with rubiez64 solution is that the rotation offset will be in world space and not in local space of the camera, so when the camera will turn it will rotate in the wrong direction
Use it
protected override void PostPipelineStageCallback(
CinemachineVirtualCameraBase vcam,
CinemachineCore.Stage stage,
ref CameraState state,
float deltaTime
) {
if (stage != applyAfter) {
return;
}
state.RawOrientation = state.RawOrientation.ApplyCameraRotation(offset, state.ReferenceUp);
}
Work for me !!! Thanks
Sorry for asking, I’m stucked at ‘add this as an extension’. Or maybe I’ve done wrong processing step 2.
How do I solve this…?
You seem to be having issues with the Cinemachine namespace.
As an experiment, try adding this test script. Does it produce errors?
using UnityEngine;
using Cinemachine;
public class TestNamespace : MonoBehaviour
{
public CinemachineVirtualCamera Vcam;
}