At the top of a script I have this 3 cameras :
public CinemachineFreeLook standUpCamera;
public CinemachineFreeLook closeLookCamera;
public CinemachineFreeLook gamePlayCamera;
Inside Update() when loading a saved game I enable/disable the cameras in this order :
void Update()
{
// When starting a new game
if (sceneName == "Game" &&
MenuController.LoadSceneForSavedGame == false && newGameStart == false)
{
SetCamerasAxisProperties(0);
playerAnimator.Play("Stand Up");
StartCoroutine(StandingUp());
newGameStart = true;
}
// When loading a game (also when continue a game)
if(sceneName == "Game" &&
MenuController.LoadSceneForSavedGame == true && loadingGame == false)
{
newGameStart = true;
Camera.main.GetComponent<CinemachineBrain>().m_DefaultBlend.m_Time = 0.1f;
standUpCamera.enabled = false;
closeLookCamera.enabled = false;
gamePlayCamera.enabled = true;
gamePlayCamera.m_XAxis.m_MaxSpeed = 300f;
Camera.main.GetComponent<CinemachineBrain>().m_DefaultBlend.m_Time = blendingTime;
loadingGame = true;
}
}
This is where I switch between the cameras :
standUpCamera.enabled = false;
closeLookCamera.enabled = false;
gamePlayCamera.enabled = true;
For testing and find the problem if I don’t switch between the cameras the active camera is the standUpCamera and this make the stuttering it’s not the player that stuttering but the camera.
When I switch between the cameras I see that the active camera is the standUpCamera than the gamePlayCamera but it’s taking few seconds before the standUp is enabled false and the gamePlaye become enabled true.
What I tried is to change the blending time :
Camera.main.GetComponent<CinemachineBrain>().m_DefaultBlend.m_Time = 0.1f;
standUpCamera.enabled = false;
closeLookCamera.enabled = false;
gamePlayCamera.enabled = true;
gamePlayCamera.m_XAxis.m_MaxSpeed = 300f;
Camera.main.GetComponent<CinemachineBrain>().m_DefaultBlend.m_Time = blendingTime;
First I set the blending time to 0 than back to the default (5)
But it didn’t help. I tried to set the blending also to 0.1f but it didn’t fix the problem.
Still it’s taking few seconds almost 3-4 seconds before the gamePlayCamera become enabled true and the standUpCamera enabled false. or maybe the blending is taking time.
Maybe I didn’t change the blending time as it should be ?
