How to get "base" position before camera shake

I’m applying a camera shake by setting the AmplitudeGain and FrequencyGain on the CinemachineBasicMultiChannelPerlin cinemachine component.

I’ve encountered a situation in which I’d like to get the position of the camera, *not including any camera shake. (*I need an object to follow the camera but it can’t be a child.)

However I can’t see where I would get the “base” camera position before the camera shake is applied every frame. I’m sure this is somewhere super obvious but I’m new to using Cinemachine.

Thanks!

You can find it in CinemachineBrain.CurrentCameraState.RawPosition.

Note that CinemachineBrain.CurrentCameraState is only valid very late in the frame, after CinemachineBrain has updated the camera position. This occurs in CinemachineBrain.LateUpdate, which has an extra late execution order. Your follow script needs to run after that. You can hook into CinemachineCore.CameraUpdatedEvent to be sure to run your code at the right time.

3 Likes