How to make two cameras: with world up override, and without world up override?

I see that world up override is inside cinemachine brain. But I have two camera behaviours.

  • One is topdown camera with a small yaw (around world Z axis) and looking at target. it has world up override.
  • The second one should not have a world up override. it looks forward and can yaw too(around world y axis)

I want to blend between theese cameras. If I use World Up Override - First camera works weird cause I am looking topdown (it starts rotating 180)
If I dont use World Up Override - Second camera works weird.

So how to have two cameras with and withoun World Up Override? How to blend between such cameras?

You can try making a custom extension for the vcam that needs a custom up override. Just set the state.ReferenceUp in the Body stage of the PostPipelineStageCallback.

1 Like

Thats great, just what I need. Thank you!

this doesn’t seem to work with a FreeLook vCam.

using UnityEngine;
using Cinemachine;

public class CinemachineCustomCameraUp : CinemachineExtension
{
    private Vector3 _up;
     
    public void SetUpDirection(Vector3 up) => _up = up;

    protected override void PostPipelineStageCallback(
        CinemachineVirtualCameraBase vcam,
        CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
    {
        if (stage == CinemachineCore.Stage.Body)
        {
            state.ReferenceUp = _up;
        }
    }
}

It should work. Can you show the FreeLook inspector?

thanks for replying so quickly even though i took so long to notice it!
i’m seeing different behavior between the override you can assign via the brain inspector and override done in the script like above. this is with CM 2.9.0-pre.6 and Unity 2023.1.0a17. i zipped up the scripts, scene, and materials (URP) if you want to drop this into a project and try it yourself. it may be worth observing this in the scene view as well - the freelook doesn’t follow the rig gizmos for some of the binding modes when overriding the up direction via script. besides testing different binding modes and adjusting the orbit size of each rig slightly, the inspector for this freelook was default values.

https://vimeo.com/793793111

8764657–1188547–Cinemachine Issue Repro.zip (25 KB)

Nice repro scene!

The problem is your OverrideWorldUp script. It should be this:

using UnityEngine;
using Cinemachine;

public class CinemachineOverrideWorldUp : CinemachineExtension
{
    public Transform up;
    public override void PrePipelineMutateCameraStateCallback(
        CinemachineVirtualCameraBase vcam, ref CameraState state, float deltaTime)
    {
        if (up != null)
            state.ReferenceUp = up.up;
    }

    protected override void PostPipelineStageCallback(
        CinemachineVirtualCameraBase vcam,
        CinemachineCore.Stage stage, ref CameraState state, float deltaTime) {}
}
2 Likes

rad! thanks @Gregoryl !