Hello,
I’m attempting to use Cinemachine to get a camera system working for my game! It’s a 3d top-down game based on a grid and what I want to achieve is for the camera to follow the target when the target reaches the screen edges. I have managed this with one caveat.
I’m using a Virtual Camera with the Framing Transposer body (no extensions) and my camera set to Perspective. When moving along the Z-axis it has the unfortunate effect of also zooming in / out along the way as evidenced in the below video. I know the documentation says that Framing Transposer was meant mainly to work in 2d and with Orthographic cameras, however, I really want to use Perspective for the visual style I’m going for. It’s true that switching to Orthographic does “work as intended” but it decidedly looks much worse.
qfddwo
Thank you in advance for any tips or help.
Try increasing the DeadZone Depth on the Framing Transposer. You should probably also add a custom extension to keep the vcam at a constant height.
DeadZone depth didn’t really do anything. I assume your second point involves inheriting this class?
https://docs.unity3d.com/Packages/com.unity.cinemachine@2.1/api/Cinemachine.CinemachineExtension.html
I’m guessing its not as easy as something like transform.position = new Vector3(transform.position.x, 71f, transform.position.z);
Mostly because I just tried that and it didn’t work 
The dead zone depth is necessary if you want the character to be able to roam within the screen dead zone you have set, without the camera adjusting. Because the camera is oblique, the guides will only be approximate. You may have to play with the values a little to get the exact composition you want.
I set something up quickly like this:
This is the result:

And this is the Lock Camera Y extension. You were right about the inheritance, and that it was a little more complicated that your simple line (but not much).
using UnityEngine;
using Cinemachine;
/// <summary>
/// An add-on module for Cinemachine Virtual Camera that locks the camera's Y co-ordinate
/// </summary>
[SaveDuringPlay] [AddComponentMenu("")] // Hide in menu
public class LockCameraY : CinemachineExtension
{
[Tooltip("Lock the camera's Y position to this value")]
public float m_YPosition = 10;
protected override void PostPipelineStageCallback(
CinemachineVirtualCameraBase vcam,
CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
{
if (stage == CinemachineCore.Stage.Finalize)
{
var pos = state.RawPosition;
pos.y = m_YPosition;
state.RawPosition = pos;
}
}
}
Ah, so its a combination of the two things. Right before I came back to see your (very helpful) reply here, I had actually just found your github with essentially this exact script on it and was working away on trying to figure it out. I suppose a combination of the two settings was required but that did to the trick, although like you said I need to tweak that depth a bit to get exactly was required. Thank you very much for your timely and helpful responses, and for teaching me.
1 Like