Position Correction confusion

I don’t understand the use of position correction. My understanding from the manual is that you can use it to add adjustments to the final position/rotation of the camera without that adjustment being fed back in for the next frame. However, despite the value of state.PositionCorrection going to zero at each frame, the value of state.CorrectedPosition does not, adding into itself until my memory overflows. What is incredible is that it even retains its value upon exiting play mode, and keeps it until I recompile the scripts. Seems to me like something going very wrong.

That does not sound right.

What version of Cinemachine are you using?
How are you setting state.PositionCorrection? Can you provide some code or a project?

CorrectedPosition = RawPosition + PositionCorrection;

So CorrectedPosition could only blow up if RawPosition is set to CorrectedPosition somewhere or if PositionCorrection is cumulative (which it should not be, because it is reset to 0).

I’m using version 2.8.9, and this is the code I used to test this, placed in a post pipeline callback extension.

if(stage == m_ResultStage){
     Debug.Log(state.PositionCorrection);
     Debug.Log(state.CorrectedPosition);
     state.PositionCorrection = Vector3.forward * 400;
}

Looking at it now, I do access the actual mainCamera object in order to call WorldToViewportPoint, because I couldn’t find an equivalent thing for a virtual camera… I think this is the problem, as when I remove my methods that call stuff from mainCamera, the PositionCorrection accumulating doesn’t happen anymore.

Something that helps is making sure to set the mainCamera transform equal to state.RawPosition at the start of the extension. I think the way it works is at the start of each frame, the virtual camera rawposition and the actual camera position are not the same, because the camera keeps the positioncorrection adjustment from before; this being what causes the issue with my calls to stuff like mainCamera.WorldToViewportPoint.