I am trying to smooth a camera I create in my game, but I can't seem to find a way to actually do this correctly.
What I have :
//Calculate the "current" Forward vector
var cameraForward =
-Vector3.Cross(-Self.forward, target.up)
.normalized.Cross(target.up).normalized;
//Rotate the camera on the Y axis of the current target,
// and X Axis based on delta.y and CurrentVerticalLook
cameraForward =
Quaternion.AngleAxis(delta.y, ViewTarget.transform.up) *
Quaternion.AngleAxis(CurrentVerticalLook, Self.right) * cameraForward;
var offset = cameraForward * CameraDistance;
var pos = LookAt + offset;
Self.Position = pos;
Self.transform.LookAt(ViewTarget.position)
So what I ahve tried :
I tried Lerping the Vector Position, I tried smoothing the delta.y based on the last N frames.
The Camera I need is something like this :
Rotate on the Around UP Axis of the target and Rotate on Right Axis of the Camera, Camera Up is always = to Target UP.
So this is sort of Orbital Camera, but I am having trouble finding the correct rotation/operations. The way its set right works, but the camera movement is jaggy, but I can't seem to find a way to add Slerp in there without messing everything.
Thanks!
Edit : <>