Virtual Cameras w/ Cinemachine in Unity 2020 — Part 6

Virtual Camera Body (Framing Transposer)

“This Virtual Camera Body algorithm moves the camera in a fixed screen-space relationship to the Follow target. You can also specify offsets, damping, and composition rules.

Framing Transposer only changes the camera’s position in space. It does not re-orient or otherwise aim the camera.

Framing Transposer is designed for 2D and orthographic cameras. But it works also with perspective cameras and 3D environments.

This algorithm first moves the camera along the camera Z axis until the Follow target is at the desired distance from the camera’s X-Y plane.

It then moves the camera in its X-Y plane until the Follow target is at the desired point on the camera’s screen.

Note: Framing Transposer ignores the LookAt target — only the Follow target is used.

If the Follow target is a Target Group, then additional properties are available to frame the entire group.”

Now, many of the settings here are very familiar, but there are some new settings.
These settings mainly revolve around the “Group Framing” ability of the Body Framing Transposer Mode.

These are the default settings for our Framing Transposer when a single target game object is selected on the Virtual Camera.

I’ve moved the VCam 2 back to the same position as the other VCams.

The Framing Transposer is better used as a side view than as a follow behind view.

It also offers some of the settings that were reserved to our Aim / Look At settings, such as Dead Zones and Soft Zones.

This makes it ideal for 2D side scroller games or any time you want the player to basically watch some event happen.

Now, something really cool we can do with this is convert our single Follow game object target into a target group holding multiple game objects.

Just click the Gear next to the Follow field on the VCam and then Convert To TargetGroup.

Next drag and drop all of the game objects you wish for the VCam to attempt to keep in the frame at all times.

As you can see in the Demo above, it does a pretty good job keeping both objects visible at the same time.
Of course we could drill down in our settings and tweak this, but I think we get the point.

Virtual Camera Body (Hard Lock To Target)

“This Virtual Camera Body algorithm uses the same position at the Follow target.

In other words, the target acts as a mounting point for the Virtual Camera.”

I want to leave my VCam 2 alone for now, so I’ll demo this on VCam 3.

As you can see above, it really means what it says.

This Body Mode attaches the camera to your Game Object and never lets go.

Note that it does not rotate with the target game object, it only moves with it.

This is a pretty barebones approach, just more or less creating a mounting point for the VCam.

Virtual Camera Body (3rd Person Follow)

“Use Cinemachine Virtual Camera’s 3rd Person Follow to keep the camera at a constant position and distance relative to a Follow target (subject to damping controls), tracking the target’s movement and rotation.

The 3rd Person Follow’s mini-rig setup defines the camera position and distance relative to the target.

With a suitable shoulder offset, this mini-rig can produce a 3rd-person camera, where the character is offset in the frame and the camera looks over the character’s shoulder.

With different settings, it can produce a first-person camera.”

As you can see, this is probably the ideal Body Mode as a basis for a 3rd person or even perhaps 1st person view with some tweaking.

This Body Mode works even better with an actual rigged character game object.

Built-in Collision Resolution

“The 3rd-person Follow component has a built-in collision resolution system, so when the target moves close to an obstacle, the camera position is adjusted so that it will never be inside an obstacle; the built-in collision resolution means the camera always keeps the target in sight, despite intervening obstacles.

When the target moves too close to an obstacle, the rig bends and stretches to keep the camera outside the obstacle but always with the target in view.”

Shaky Movement, Steady Aim

“When combined with the Cinemachine3rdPersonAim extension, the result is a powerful rig that can maintain steady aim for a shooter-type game, even when the camera movement is shaky or noisy.

Cinemachine3rdPersonAim re-adjusts the camera orientation to maintain a fixed point at the center of the screen, correcting for variations due to hand-held camera noise or shaking target motion.”

We can the aim extension by clicking Add Extension, and then Cinemachine3rdPersonAim.

In the settings we can adjust the Shoulder Offset as well as Vertical Aim Length to achieve our desired effect.

The Camera Side setting determines if you want to offset based on the left or right shoulder.

The Obstacles — Camera Collision Filter allows us to choose a layer that this VCam will collide with such as walls or other obstacles.

You will need to add the CinemachineCollider Extension though for it to work!

The Camera Radius setting let’s us determine how close the camera can get to a collider before it takes effect.

Virtual Camera Body (Orbital Transposer)

“This Virtual Camera Body algorithm moves the Unity camera in a variable relationship to the Virtual Camera’s Follow target.

It optionally accepts player input, which allows the player to dynamically control the position of the camera relative to the target.

The Orbital Transposer introduces the concept of heading, which is the direction in which the target is moving or facing.

Orbital Transposer attempts to position the camera so that it points in the same direction as the heading direction.

By default, this position is directly behind the target. Control this relationship by adjusting the Heading Bias property.

If you attach an input controller to the Orbital Transposer, then the player can also control the camera.

This allows the player to move the camera to any spot on an orbit around the target.

Configure the Orbital Transposer to take its input from any axis that you set up in the Input Manager.

Or control the value directly using a custom input system.

Orbital Transposer optionally re-centers the camera automatically.

When Recenter To Target Heading is checked, Orbital Transposer automatically moves the camera back to the target heading.

You can specify the length of time to wait after it has detected no user input and the speed of the recentering.”

Now, I have target1 game object in both the Follow and Look At fields for this example.
Prior to now, it has always been just Follow.

The Aim Mode is set to a default Composer and I haven’t changed any of the default Orbital Transposer (Lock To Target With World Up) settings.

As you can see once my VCam 4 takes over, there is this orbital plane, a red circle in the scene, which the camera uses to rotate around while keeping the target game object centered in the screen.

This looks like an Ideal VCam mode for Character Setup screens and things like that, so that players can view their customizations in a 360 degree view of their character.

Of course we have some settings to tweak this mode as well.

Now, I’m modifying the Tracked Object Offset X, Y, and Z values as shown above.

The X and Y predictably deal with vertical and horizontal offset while the Z actually controls the circumference of our circle, bringing the camera closer to or farther away from our target game object.

You can also adjust the Tracked Object Offset under the Aim (Composer) settings to further fine tune the camera offset.

Adjusting the Heading Definition & Bias will change what exactly our VCam is targeting on the target game object as well as even adjusting the speed of camera movement based on the target game object’s velocity.

I’m happy with Target Forward for now.

Recenter to Target Heading allows the camera to automatically recenter on the target game object regardless of player input or if the target game object has stopped moving.

The Recentering Time determines the angular speed of the recentering while Wait Time is the delay before the recentering will occur.

The X Axis settings let us move the VCam around to a particular degree of the circle the camera “rides” by adjusting the Value field.

We can also set a limited range for the VCam by modifying the Value Range to say, -30 degrees and 30 degrees.
The camera will no longer move past these angles on the circle track.

Speed, Max Speed, Accel Time, and Decel Time are self-explanatory.

The Input Axis Name and Value corresponds to the Unity Input Manager axis.

In the next article we’ll look into the Tracked Dolly Body Mode.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

.Net Core 3.1 Help Pages using Swagger

June 2022 Frontend Updates: Color and Fonts, UI Animations, Best Practices for ARIA and IE Farewell

Git Workflow Best Practices

How to Become a Successful Self-Taught Developer (Part 2)

How to crop an image with CSS (the simple way)

Third Party Service Providers Transparency

How Elon Musk Made Our “Flock” Flop — How We Became RemeX

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
GameDev Dustin

GameDev Dustin

More from Medium

Virtual Cameras w/ Cinemachine in Unity 2020 — Part 2

What layout works for me in Unity

Cinemachine: 3rd Person Follow, Orbital, and Transposer

Adding damage effects to the player ship.