Virtual camera blend issue

Hello there !

We decided to use Cinemachine as our camera solution and we are facing a weird blend behaviour.

As you can see, when enabling the second virtual camera, instead of blending the camera target smoothly, it keep looking at the first target at the beginning of the blend and then switch to the second target.

Two questions :

  • Its this the desired blend behaviour ?
  • Can we change this somehow ?

Thanks for your answer and have a nice day ! :slight_smile:

In fact this is the intended behaviour. When you blend between vcams with different LookAt targets, the LookAt point during the blend is not a linear lerp between the target points (which is what you are looking for, I believe). Instead, it is a spherical linear interpolation that is more robust under more circumstances.

There are 2 ways to change this.

  • Remove the LookAt target from one or both of your vcams. This will force CM to simply slerp the camera rotations, giving you the effect you want in this case, or
  • Change the way CM interpolates the LookAt target. Go to CameraState.cs, around line 170 or so, and make this mod:
                #if false
                state.ReferenceLookAt = state.CorrectedPosition + Vector3.Slerp(
                        stateA.ReferenceLookAt - state.CorrectedPosition,
                        stateB.ReferenceLookAt - state.CorrectedPosition, adjustedT);
                #else
                state.ReferenceLookAt = Vector3.Lerp(
                        stateA.ReferenceLookAt, stateB.ReferenceLookAt, adjustedT);
                #endif

Warning: this is a global mod, and will affect all CM cameras. Use at your own risk

1 Like

Hey, thanks for your quick answer !

As we want to keep the LookAt target, I’ll go for the second proposition ! :slight_smile:

Have a nice day !

Please let me know how that works out for you, and whether the mod creates other blending weirdnesses. There is some controversy here about what is the best blending strategy for the LookAt target, and we might have to make this choice more explicit in future releases. Thanks.

Hi Gregory,

Thanks for sharing that trick. I know this is an old thread, but It would be great if this were exposed as an option in the future. I found it helped smooth out some camera weirdness related to blending from a view looking out to one side back to a follow cam behind a moving object. I can send you more details if you’re interested. Thanks! We’re really enjoying the new tools!

Dylan

CM 2.1 (available in beta) has the modified version as standard. Consensus seems to be that it’s better that way.

Hi,

I did encounter some weird blend that occur when the start and the end point have opposite forward. This blend is between a Virtual Camera as a tracked dolly (not auto) and a cinemachine external camera

(Preview : Imgur: The magic of the Internet )

Also, I tested it with the v2.1 RC and it’s still happening.

Have a nice day !

I can’t really tell what’s happening here since you didn’t show Hierarchy/Inspector windows.
Could you upload this/make repo project and send it to @Gregoryl / @Adam_Myhill , It would really help.
Thanks.

Ok, unfortunately I can’t make a repo because we have an internal git but I’ve made a showcase (unity project). I will send it by PM to @Gregoryl .

Thanks !

@d-grandry Hi Dorian,

The problems is due to Cinemachine attempting to negotiate a difficult blend (one that involves a travelling Lerp right through the object being looked at) without sufficient information to do it properly.

The CinemachineExternalCamera, while useful in some situations, is lacking a key piece of essential information: the LookAt target. The blender needs to know what the camera is looking at, otherwise it’s stuck doing what is essentially a Slerp, which can give inferior results in circumstances such as these.

I would suggest, instead of using CinemachineExternalCamera, that you add a CinemachineVirtualCamera to the Player Orbital camera. Sets its aim and body to Hard Constraint, and - importantly - set its lookAt target to the point that the Player Orbital camera is looking at. Then the blends will be nice.

Let me know if that works for you.

@d-grandry Hi again,

Another (perhaps better) option is to just add the LookAt field to the CinemachineExternalCamera, to provide the missing information. I’ve done that here, and it seems to do the trick in your scene.

3234397–248398–CinemachineExternalCamera.cs (2.57 KB)

Hi,

So I did try both solutions and they both work. But I have a question does the lookAt in cinemachineExternalCamera will be added in a further version ? (To know if we have to re-apply this when updating cinemachine later on)

Thanks !

Yes it’s a good addition and it’s going into the next beta

Ok, thanks ! Have a nice day.