Unity Virtual Camera Cinemachine Tutorial

Prepare

Install the Cinemachine package in PackageManager.

1. CinemachineBrain Components

It is equivalent to the total management of virtual cameras.
insert image description here
Parameter introduction:
Live Camera: the currently displayed camera
Live Blend: show the progress when the camera is overridden
Show Debug Text: display the currently used camera in the Game window
insert image description here
Show Camera Frustum: display the view cone
Ignore Time Scale: Whether it is affected by TimeScale
World Up Override: Override the Y-axis by yourself to prevent the gimbal from deadlocking.
Update Method: Update method, select the default SmartUpdate.
Blend Update Method: The Update method when the camera is blended.
Default Blend: The curve for blending, such as linear or Ease, can also be customized.
Custom Blends: Custom blending schemes.
Events: This event will be fired when the virtual camera is activated. If blending is involved, the event fires on the first frame of the blending.

2.2D virtual camera

The virtual camera we need can be created by selecting Cinemachine in the menu bar. (Note that the camera should be changed to Orthographic)
Parameter introduction
Status Live: Checking solo means only using this camera.
Game Windows Guides: Whether to display wireframes in game windows
insert image description here

Save During Play: Check to save the modification of the component at runtime.
Priority: Determine which camera to display first according to the value. The larger the priority, the higher the priority.
Follow: the camera follows the target
. Look At: look at the target, and the camera does not move (basically use 2D, most use Follow)
Mode Override: choose
Ortho for the camera mode Filed: Field of view size in Orthographic mode
Dutch: z-axis rotation
Damping related (damping): lens easing effect
ScreenX and ScreenY: lens offset
Dead Zone: the lens will not always follow in the dead zone.
Soft Zone: In the soft zone the camera will slowly follow the target. Beyond the soft zone the camera will teleport to follow.
Unlimited Soft Zone: Unlimited soft zone (remove the red part)
The black part in the figure below is the dead zone, the blue part is the soft zone, and it will teleport beyond the red part.
insert image description here
Lookahead Time: If set, the target point will be offset in the direction of movement, such as in a 2D game, you can see the front view.
Lookahead Smoothing: Smoothing value.
Lookahead Ignore Y: Ignore Y-axis influence. (2D games are often checked, otherwise the lens may be unstable)
The yellow dot is the offset brought by setting Lookahead.
insert image description here
We can add restrictions to the virtual camera by selecting Extensions->AddExtension->CinemachineConfiner.
insert image description here
insert image description here
There are two ways, one is to create a new empty object and add the PolygonCollider2D component to adjust the size and assign it. Another is as shown below.
insert image description here
There are two kinds of switching between virtual cameras that we commonly use. One is to set Priority, which will display the higher priority. The other is to give priority to the active camera, which can be switched by activating and deactivating the virtual camera.

3. 3D virtual camera

Only the differences from 2D virtual cameras are explained here.

Parameter introduction:
Field Of View: The size of the field of view in Perspective mode
Near Clip Plane: The distance between the part below and the camera
insert image description here

Far Clip Plane: The distance between the image below and the camera
insert image description here
Noise: Camera effect
Noise Profile: Effect selection
Amplitude Gain: Amplitude
Frequency Gain: Frequency

When ctrl+shift+fadjusting the camera position, it is best to check the solo of the target camera, otherwise there may be a bug to adjust all cameras.

3D lens limitations
insert image description here
insert image description here

Control the virtual camera with Timeline

Create Timeline

We can open the Timeline panel in Window->Sequencing->Timeline. If there is no such option, it can be downloaded in Window->PackageManager. Then select the object in the scene and click Create to create a new Timeline.
insert image description here
After creation, it will come with an Animation Track, and an Animator will be added to the selected object. We don't need to delete it directly for the time being.
We can create a Cinemachine Track by right-clicking on the left or clicking the plus sign.
insert image description here
After creation, you need to add a Cinemachine Brain component to the Track.
insert image description here
Then drag the virtual camera directly into the Track (or right-click and select Add Cinemachine Shot). And you can drag and drop modules to achieve mixing effects.
insert image description here

lens shake

lens shake

Guess you like

Origin blog.csdn.net/qq_39162826/article/details/110531752