Here is a CodeSandBox Link
I’m looking to recreate flight controls like the one for Unity from this repo. From what I understand, it uses a mouseAim
rig and a cameraRig
. In the codesandbox I have set up a basic mouseAim
rig that I believe is pretty much the same idea.
However I am unsure on how to make the camera follow the mouseAim.target
location like the gif on the repo. The code that rotates the camera in the repo is like this:
// Smoothly rotate the camera to face the mouse aim.
cameraRig.rotation = Damp(cameraRig.rotation,
Quaternion.LookRotation(mouseAim.forward, upVec),
camSmoothSpeed,
Time.deltaTime);
// Damp function
private Quaternion Damp(Quaternion a, Quaternion b, float lambda, float dt) {
return Quaternion.Slerp(a, b, 1 - Mathf.Exp(-lambda * dt));
}
I was thinking that I need to set up some sort of orbit camera rig first, but not sure if there is a simpler method. I appreciate any guidance