Cinemachine Virtual Camera Switch target at runtime in virtual camera, its causing jerk?

Hi, @Adam_Myhill, I am using cinemachine virtual camera for my racing game. And I am using multiple virtual cameras, to show different views in racing. But I am facing one issue with virtual camera. Its when I am assign a new target from previous target to the virtual camera its suddenly changing the camera position. So its looking like a jerk. Can we have smooth movement when changing from previous target to new target in virtual camera?

It would be great if you help me on this. Thanks in advance

@manish191 It is by design that a target switch on a vcam acts as a cut, not as a blend. The official way, if you want a nice smooth blend, is to have a second vcam on the new target, enable it (or boost its priority), and let the Cinemachine blender make the transition.

Do you have a special reason why you need to make this transition using a single vcam?

1 Like

Hi, Gregory, Thanks for the response. Actually, I am using Cinemachine for a racing game. Where Player will be running and Also I am using multiple VCam, But the problem is target switching is very frequent in racing. Right Now I am using 6 Vcam to cover full race track. Also If I Use more VCam in game is there any performance issue? suggestion please

You can have as many vcams as you like. There is a small cost for each active one, as it will be following its target, but it’s not rendering or anything like that. You can eliminate even that cost by disabling the vcams, and only enabling them when you switch to them.

3 Likes

Thanks, Gregory for the response. I will Make sure to enable and disable according to there requirement in game. I will make the change lets see how it will work. Thanks

Cool, exactly the reply I was looking for. Avoids a more complicated path animation!

1 Like

I’m having a similare problem where, in my case, I would like to switch from a virtual camera to an other, but have a transition that follows along a Dolly Track. I’m not sure if I can actually do that, but the reason I want to use a Dolly Track is that my camera is going to move around in a mansion and I would like it to go throw some specific corridors (follow the Dolly Track). The other reason I want to use a Dolly Track is that I don’t want my camera to go throw walls.

If it’s not really possible, maybe have one virtual camera on a dolly and changing the follow and look at, but still have it make a transition along the track (I tried just changing the follow and look at by code, but it just cut instead of doing a transition)?

Interesting. You want to transition from camera A to camera B, but you want that transition to follow a dolly track.
What are camera A and camera B doing? Are they also on tracks? Are they FreeLooks, or follow cams, or something like that?
What do you want the camera to be looking at while it’s transitioning back to camera A?

I can offer this idea, which may or may not be appropriate (I would need more info about your cameras):

Suppose you make camera C, which is a dolly along the transition track. Set its follow target to be an invisible gameObject, which you will manually lerp from camera A’s position to camera B’s position - right through walls etc). When it’s time to transition, you do this:

  • Activate camera C (CM will transition from A to C)
  • Lerp the invisible object from A to B (CM will cause camera C to seek the closest point on the track to the invisible object, but it will stay on the track)
  • When the lerp is finished, activate camera B (CM will transition from C to B)
1 Like

Gregory I am having the same need as Suree 9. I will try your suggestion of lerping an invisible target. But it seems like such a great omission on the track and dollly cam.

The use case is a cutscene. We would like the camera to follow a path as we explore the scene but also target different points of interest as it follows its path. Seems pretty standard.

Isn’t the track and dolly the correct camera to use.

Yes, use the track and dolly. You don’t need an invisible object - just animate the vcam’s position on the track.

5463114--558330--upload_2020-2-10_9-48-0.png

You can make multiple such vcams on the same track, in the same position, moving at the same speed, but with different LookAt targets. At the appropriate times (maybe with TriggerVolumes - look at CinemachineTriggerAction for a nice helper script) adjust the priorities of the vcams to transition smoothly between them

1 Like

I had the same requirement as @ertsnom99 to vary lookat targets along a dolly track. I ended up with a timeline that has an animation track for each camera, animating the path position identically. And a cinemachine track to switch between the cameras. It works, but a little clunky. Would be nice to have a single camera a allow smooth blending between lookat targets

@hawaiian_lasagne the easiest way to do that would be to have an invisible object which is the actual LookAt target, and animate it from one place to the next.

But we take your point: it would be nice to have a way to smoothly change targets in a single vcam. Thanks for the suggestion.

@Gregoryl Ah I see what you mean, thanks that is a lot cleaner :). I now only have a single camera, and a single lookat target, rather than 3 cameras and 3 lookAtTargets.

And, my timeline went from this:

to this:

Cheers!

1 Like

One camera is much simpler and cleaner in code, would be nice if we could choose the speed of camera transition after follow target changes! :confused:

1 Like

Seconding this, as it can lead to messier code for some use cases to have multiple virtual cameras. In 2D, I only really need one camera, but I regularly change its orthographic size. If I want to change follow targets at runtime, I guess I need other virtual cameras for the other targets, but I’ll have to manually mirror the same ortho size to all of them.

It’s doable, but perhaps more awkward than it needs to be, since all I’m trying to do is pan during a cutscene or with the player’s analog input, and then return to following the player afterward. But when I re-set the player as the follow target or re-enable the Cinemachine brain, it jumps straight back instead of smoothly returning to default.

Transitioning from a non-CM camera to a CM-driven camera will not lerp the camera to the desired position. For the cameras that you want to control directly, use a CM vcam instead of a Camera component. While that vcam is active it will fully control the main camera. If you set it up that way, you have the possibility of using CM blending, even to/from vcams that are 100% driven by your custom code.

Your cutscene can blend to/from the player cam without deactivating the Brain or changing the target of the player cam.

1 Like

Thanks. Yeah, it feels funny at first, but ultimately I guess it’s better to use multiple virtual cameras, and just set them to Do Nothing if you want to control some of them by code. My player input camera is more or less working now.

1 Like

Yes, exactly.

+1 for this!
I have a Dolly and I do want to change the Target between some points to be able to get some more interesting angles on some path positions. I have done a code to make this but I got “direct cuts” instead of transitions. Is this still not possible?

The easiest way to do this is to use an invisible object as target and change its position

2 Likes