Hey Cinemachine guys, I was having an issue today with enabling/disabling the camera with the CinemachineBrain component. I’m actually controlling the Cinemachine camera with a rigidbody for some floaty-ish controls so I needed to set the brain update to FixedUpdate. However, after disabling and then reenabling the GameObject with the brain and camera it simply stops updating. I disable because the camera is a temporary controllable spectator camera.
In my debugging I checked CinemachineBrain.cs and noticed that StartCoroutine(AfterPhysics()) is only run in Start(). If I move it to OnEnable I can now enable/disable the GameObject successfully :). I just started learning Cinemachine a couple of days ago, so maybe I’m overlooking something but it makes sense to me to put a coroutine in OnEnable instead of Start since disabling will cancel all running coroutines on that GameObject.
I’ll probably go with this fix and make the change locally, so I’m just hoping you guys can make the change official
Hey @scvnathan thanks for finding that. You’re absolutely right, it should be in OnEnable. We’ll include a fix in the next CM release.
Note: you will also need to stop the coroutine in OnDisable.