Hi, I’m working on a strategy/management game. To zoom in and out I’m using a CinemachineMixingCamera to blend between 4 different cameras (Map, Far, Mid, Close). This works fine, as long as Time.timeScale is set to something above 0. Unfortunately, when Time.timeScale is set to 0, i.e. when the game is paused, the player can no longer zoom in/out.
What I’ve tried:
- Setting UniformDeltaTimeOverride (CinemachineCore.UniformDeltaTimeOverride = 1f / 60 )
- Manually calling InternalUpdateCameraState (mixingCamera.InternalUpdateCameraState(Vector3.up, Time.unscaledDeltaTime);
Thank you for your help!
Here is the code I use for updating the weights:
[Bind(Bind.From.ComponentInHierarchy, scene: Bind.SceneMain)]
public class CameraSimpleMixer : MonoBehaviour
{
CinemachineMixingCamera mixingCamera;
public float transition;
public float factor = 1, exp = 1;
public float mapCutoff = 0.025f;
void Start()
{
mixingCamera = this.GetComponentNotNull<CinemachineMixingCamera>();
StartCoroutine(UpdateRoutine());
}
IEnumerator UpdateRoutine()
{
while (this != null)
{
_Update();
yield return null;
}
}
void _Update()
{
CinemachineCore.UniformDeltaTimeOverride = 1f / 60;
Debug.Log($"{Time.unscaledDeltaTime} [Time.unscaledDeltaTime]");
if (mixingCamera != null)
{
if (transition < mapCutoff)
{
mixingCamera.m_Weight0 = 1;
mixingCamera.m_Weight1 = 0;
mixingCamera.m_Weight2 = 0;
mixingCamera.m_Weight3 = 0;
}
else
{
mixingCamera.m_Weight0 = 0;
mixingCamera.m_Weight1 = Val(1,0);
mixingCamera.m_Weight2 = Val(2,0.01f);
mixingCamera.m_Weight3 = Val(3,0);
}
}
}
[Pure] float Val(int v, float min)
=> Max(min, Clamp01(1 - Pow(Abs((transition - v) / factor), exp)));
}