Why does your camera flip upside down?

Look up far enough and you go over the top.

Why does your camera flip upside down?

The problem

Pitch with no limit.

protected override void OnUpdate(){    EyeAngles += Input.AnalogLook;}

Keep moving the mouse up and pitch passes 90, straight up. Then you're looking backwards, upside down.

The fix

Stop at straight up and straight down.

Clamp the pitch between -90 and 90. Leave the yaw free so you can spin all the way around.

pitch→-90 to 90
yaw→free

The fix in code

Copy, clamp, put it back.

protected override void OnUpdate(){    var e = EyeAngles;    e += Input.AnalogLook;    e.pitch = e.pitch.Clamp( -90, 90 );    e.roll = 0;    EyeAngles = e;}

Angles is a struct, so edit a copy and assign it back. The controller we build on does exactly this.

Watch out

Why zero the roll?

Roll tilts the horizon. Mouse look should never add any.

pitch
up and down, clamped
yaw
left and right, free
roll
tilt, always 0

The rule

Clamp the pitch. Free the yaw.

pitch
Clamp( -90, 90 )
yaw
no limit
roll
0