Hey guys,
I have two Virtual Cameras I blend between with Ease In Out.
VCamera A is a Orbital Follow with Hard Look At - Imagine a Drone flying around a Target
VCamera B is a Follow with Hard Look At - Imagine a strategic top down view. The actual forward vector is -Vector3.up;
Blending between those does work well position wise. Blending rotation wise works somehow.
It does tilt and keep the LookAt in Focus. It doesn’t roll though.
If you look at the Screenshot it shows the situation one frame before the blend is complete.
Red is the Frustrum of the Virtual Camera it is blending to.
White is the actual Cameras Frustrum. As you cann see it does look in the right direction, but it is off in one Axis though. Speaking from the current point of view it should turn left. It is jumping in the correct rotation with the final Frame (and therefor not blending)
The blend between other virtual cameras works without a problem. What am I missing?
Cameras looking straight up or straight down are always a little tricky, but generally there are ways to get the desired behaviour. It looks like you’re getting some undesired roll. This is likely due to gimbal lock.
An easy fix is to have your top-down camera follow at a slight angle from the pure vertical. Even a 1 degree difference is enough.
If you really want your drone cam to look straight down, you can make a custom extension to override its Up vector to be pointing forwards.
Once you do either of those things, then your blends should work correctly.
Here is a simple Cinemachine extension to use the target’s forward vector as camera up. Try adding it to your drone camera.
using Unity.Cinemachine;
[SaveDuringPlay]
public class CustomCameraUp : CinemachineExtension
{
public override void PrePipelineMutateCameraStateCallback(
CinemachineVirtualCameraBase vcam, ref CameraState curState, float deltaTime)
{
if (vcam.LookAt != null)
curState.ReferenceUp = vcam.LookAt.forward;
}
protected override void PostPipelineStageCallback(
CinemachineVirtualCameraBase vcam,
CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
{
}
}
An offset of 0.1 already worked. Interestingly the higher the offset, the earlier the camera “starts” turning in the missing direction. Thanks.
1 Like