How do you improve Cinemachine Virtual Camera Transitions?

We are using C# to switch to a crash cam when a collision is detected. In the video below at the 20sec mark you can see that the camera transitions cuts instead of smoothly changing.

Any ideas on why this happens?

The first collision was very easy to miss at the :08 mark.
The 2nd went as planed :10.
The 3rd has a unwanted camera cut during transition :20.

I was hopping someone might have input.

Sorry for the delayed response, my notifications were accidentally disabled and now I’m catching up.

Have you solved this problem? If not, can you please give more information about your setup? How are you triggering the transition? What are the CM Brain’s default blend and blend settings? Which version of CM are you using?

Thank you for the reply. We are using CM Version 2.8.9 in unity 2021.3.17f.
I have not solved this issue. If the blend from CrashCam to ** ANY CAMERA** takes longer than 2s it will Cut.

Here is a screenshot of the brain settings. I have highlighted the CrashCam in Green.

We’re using the following collision Enter and Exit to fire Unity Events to set camera priority.

public void OnCollisionEnter (Collision obstacle)
   {
       if (obstacle.gameObject.CompareTag("Obstacle") & (rb.angularVelocity.magnitude >= 2))
       {
           collisionEvent.Invoke(); //sets CrashCam to highest priority.
           crash = true;
           ExitBool = false;
           TimerCollision = 0;
       }
   }
   
   public void OnCollisionExit(Collision obstacle)
   {
       if (obstacle.gameObject.CompareTag("Obstacle"))
       {
           crash = false;
           GroundedBool = false;
       }
   }
   
    private void FixedUpdate()
   {
       **if(crash == false)**
       {
           TimerCollision += Time.deltaTime;
           if(TimerCollision >= 1f & (rb.angularVelocity.magnitude <= 3))
           {
               crash = true;
               ExitBool = true;
               //Debug.Log(TimerCollision);
               
               TimerCollision = 0;
               exitEvent.Invoke(); //sets CrashCam priority  to 0.
           }
       }
   }

You have quite a complicated setup as well as some custom scripts, the interactions of all of which I’m not able to model in my head with the current information.

I would suggest you add some debugging to try to figure out what’s happening. First thing is to enable this so that you can see CM’s blend state:
image

Next, wherever you set a vcam’s priority in your code, add a Debug.Log so you can trace it.

You might also try to simplify your custom blends asset, it has quite a few redundant lines in it. Anything you can do to simplify would help with the debugging.

We are in the middle of a playtest phase. I’ll get back to this with a simplified setup once the test is over.

1 Like

In this new video I have only 3 Cams.
One is active when landed.
One is active when flying.
One is activated after the player collides with an obstacle.

When sitting on the ground the LandedCam has the highest priority of 9. Once the airplane is in the air the LandedCam priority is set to 0. The FollowCam is now the active Cam as it has a priority of 1. The FollowCam priority never changes. If the airplane collides with an obstacle the CrashCam priority is set to 8. After 1 second and the Aircraft spin is under a threshold CrashCam priority is set to 0.

Camera hierarchy as follows.
FollowCam (25-99) 1
FollowCam (CrashCam) 8
LandedCam 9

You can see at 11 seconds that we are transitioning from CrashCam back to FollowCam when the camera cuts and looses visual sight with the airplane.

I am simply trying to get a smooth transition from CrashCam to FollowCam. Unfortunately it’s in unpredictable conditions.

I have truncated logs to show the transitions only.

	UnityEngine.Events.UnityEvent UnityEngine.Events.UnityEventLandedCam Priority = 9
	UnityEngine.Debug:Log (object)
	AirplaneController:FixedUpdate () (at Assets/Scripts/Flight/AirplaneController.cs:704)

	UnityEngine.Events.UnityEvent UnityEngine.Events.UnityEventLandedCam Priority = 0
	UnityEngine.Debug:Log (object)
	AirplaneController:FixedUpdate () (at Assets/Scripts/Flight/AirplaneController.cs:715)

	OnCollisionEnterUnityEngine.CollisionCrashCam = 8
	UnityEngine.Debug:Log (object)
	ObstacleCollision:OnCollisionEnter (UnityEngine.Collision) (at Assets/Scripts/ObstacleCollision.cs:26)

	TimerCollision = 0 CrashCam = 0
	UnityEngine.Debug:Log (object)
	ObstacleCollision:FixedUpdate () (at Assets/Scripts/ObstacleCollision.cs:62)
	//ISSUE OCCURS HERE

Here is a shot of the new brain Logic.

LandedCam

FollowCam

CrashCam

I’m not seeing any cut in your video. Everywhere the debug is indicating a smooth transition:

The % goes smoothly from 0 to 100 in all cases.

Have you tried enabling “Inherit Position” in the vcams?

Interesting.
Maybe the issue has to do with the rotation of one camera to the other.

here is the screenshot of the exact moment we are getting the undesired behavior.

Do you have high damping settings on any of the composers?

Only Damping is the FollowCam Body.

X: 0
Y: 0
Z: .3
Angular Damping Mode: Euler
Pitch: .5
Yaw: 2.5
Roll: 2

Our goal is to prevent the player from getting sick when they crash into an object.
Is there a different way I should research?

If you’re trying to figure out why the plane goes out of frame momentarily during the blend, I would do it by elimination. Turn off all the damping. Does it still happen? Is there lookahead or anything like that? Turn it off. Is the LookAt target actually inside the plane at all times? Gradually change things to make it more and more rigid, until it stops happening. Then one by one put stuff back until the problem returns. Perhaps it’s a combination of things.

We’ve ballistically solved this issue by adjusting the friction on materials.