I’m just trying at the moment to construct a camera system similar to the one that’s seen in Super Mario World on the SNES using Cinemachine.
Basically I have a Cinemachine 2D camera that follows the player(represented by a red rectangle) but I don’t want the virtual camera to follow the player when it jumps very high. I want the vertical axis of the virtual camera to be stable at all times.
I have the deadzone height of the camera set at its maximum value but it still doesn’t seem to be high enough to prevent the camera from following the player vertically once the player reaches a certain height.
Hmmm… you seem to have indeed tripped over a limitation. The soft zone can stretch to 2, but the dead zone can only stretch to 1. There is no good reason for that, so we will fix it for the next CM release. Thanks for letting us know!
In the meantime, there are a couple of ways to implement a workaround:
You can set the screen Y to 0.5, and then the dead zone height of 1 will be enough to fill the screen. You will just need to start your camera off on the ground - then the dead zone will take care of keeping the camera from moving vertically.
You can add a custom extension to manage the vcam’s Y position. Here is one that locks it to a specific value. You can modify it to handle the camera Y any way you like.
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.Body)
{
var pos = state.RawPosition;
pos.y = m_YPosition;
state.RawPosition = pos;
}
}
}
faced the same problem, the solutions proposed to you do not help to solve situations, since the center of camera watching the character is moves, but must remain static.
If you want the camera to remain 100% static, then don’t follow the player.
If you want the Y position of the camera to remain static, but track the player’s X position, then you can attach the script from the post above.