Mouse look "Snapping" in odd directions on enable

I’m working on a first person project and I’m currently using the default mouselook script. I’m having an issue when transitioning out of cutscenes where, upon enabling the script again (entering the cutscene disables it), the view will suddenly snap to a random direction. This is most apparent when transitioning out of cutscenes but it also occurs when the level first loads, meaning the player could end up looking any random direction when it starts instead of forward. I should also note that during the whole time, the cursor is locked in the center of the screen. I’ve tried a variety of mouselook scripts, both of my own creation and others freely available, but all have the same problem. I’m guessing it has to do with how unity handles input from the mouse, but I’m not knowledgeable with scripting inputs to really know. Is there a way to handle the input differently that can prevent the view from snapping in unpredictable directions?

Disable the mouse look script when a cutscene starts and enable it again when a cutscene ends so new inputs aren’t polled. Alternatively, record the last orientation for the player at the start of a cutscene and explicitly set it back at the end.

I figured out a solution: when the cursor is locked, technically it is placed at the center of the screen, but when it is locked for the first time (for instance, when the scene initializes), the player moving the mouse will cause it be read as “jumping” from its original place to the center of the screen (even if it is displaying at the center of the screen already). Essentially, if the cursor is locked and you’re using input.getaxis(“Mouse X/Y”), the first time you move the mouse, the number that is returned by getaxis will see a massive spike. After that, it’s fine and behaves as its should. So, I coded a lockout after the cutscene ends that keeps the mouse look locked as long as the player doesn’t move the mouse. If they move the mouse, it remains locked just long enough to prevent the spike from registering, and then releases control back to the player. From there, it’s smooth sailing.