Rotate the camera around actor with no parenting/springarm

This pretty much works:

the only issue I have left is when I raise the camera high above the actor by Y (close to being “top down”) it swivels to the side and reverts i.e. if I was behind the actor’s back, slowly raising camera up until almost look at actor’s “head”, the cam swivels to the left and the wraps to actors “front”

very odd because I clamp it

that swivel near top-down is classic gimbal flip from lookat, not your clamp. when pitch gets near -90 yaw goes unstable and wraps to front.

i keep yaw/pitch as separate floats instead of feeding lookat back. yaw += mouseX * sens, pitch = clamp(pitch + mouseY, -80, 80). note 80 not 89, leave margin. then:

Offset = FVector(Cos(Pitch)Cos(Yaw), Cos(Pitch)Sin(Yaw), Sin(Pitch)) * Distance

CamPos = ActorPos + Offset

SetWorldLocationAndRotation(CamPos, FRotator(Pitch, Yaw, 0))

dont derive yaw from the lookat result, thats what snaps it. works with no springarm or parenting.