Hi there, I’ve got two camera positions I’d like to blend between as the player crosses a bridge in a 2D game. When the player is at position 0 the camera is also at position 0 and is close up (smaller orthographic size). When the player is at position 1 the camera is also at position 1 and is zoomed out (larger orthographic size). And when the player is in between the two positions the camera is blended between camera 0 and camera 1.
I’m currently planning on using a single dolly track with two cameras that follow the track based on the player’s position (using AutoDolly), and a CM Mixing Camera to blend between the different zoom sizes that the cameras have also based on the player’s position.
Is this the best way to do this or am I missing a way to control the zoom via the dolly track? If it is, what’s the smoothest way to control the blend weights on the mixing camera via code?
Thanks very much!
Hi,
What I would do is the following:
Option 1:
Have two cameras:
-
Camera A - this is the zoomed in camera, that is in complete control at position 0.
-
Camera B - this is the zoomed out camera, that is in complete control at position 1.
Both of these cameras are following the player.
Then, based on the position between position 0 and position 1, I would blend between them using a MixingCamera.
Option 2:
Have a dolly track and one vcam on the track. This vcam is following the player. Based on the position between position 0 and position 1, you change the zoom parameter. You should do something like Lerp(orthosizeSmall, orthosizeBig, v), where v is based on the position between position 0 and position 1.
Since you are in orthographic size, this means you are controlling Lens → orthographic size property.
The advantage of Option 1 over Option 2 is that you can have completely different Camera A and Camera B and the blending will be nice. For example, you could have different post processing on your cameras - Camera A Color, Camera B grayscale.
You can also combine these two methods. Having a mixing camera with Camera A and B on the dolly track.
I think Lerping should be good - https://docs.unity3d.com/ScriptReference/Mathf.Lerp.html.
Have a look at our MixingCamera example scene. You can get our examples scenes from the package manager.
1 Like