I'm trying to make aircraft style controls where if you roll and then pitch than the new pitch is based on current roll of the aircraft. Same for when you pitch than roll.
if (Cursor.lockState != CursorLockMode.Locked) return;
float mx = Input.GetAxis("Mouse X") * sensitivity;
float my = Input.GetAxis("Mouse Y") * sensitivity;
if (inWater)
{
_pitch -= my;
_roll += mx * rollSpeed * Time.fixedDeltaTime;
// Aircraft-style controls
if (_cameraRoot)
{
Quaternion rollQuat = Quaternion.Euler(0f, 0f, _roll);
Quaternion pitchQuat = Quaternion.Euler(_pitch, 0f, 0f);
_cameraRoot.localRotation = rollQuat * pitchQuat;
}
}
This is my look function while swimming. I have asked so many ai chat bots about this but none of them gets it right.