Я делаю игру с самолетом, и мне нужно, чтобы получить полет самолета.Ниже приведен рабочий код для установки высоты тона, но я не могу понять, что такое рыскание.
private void _CalculateRollAndPitchAngles()
{
// Calculate roll & pitch angles
// Calculate the flat forward direction (with no y component).
Vector3 flatForward = transform.forward;
flatForward.y = 0;
// If the flat forward vector is non-zero (which would only happen if the plane was pointing exactly straight upwards)
if (flatForward.sqrMagnitude > 0)
{
flatForward.Normalize();
// calculate current pitch angle
Vector3 localFlatForward = transform.InverseTransformDirection(flatForward);
m_pitchDegrees = Mathf.Atan2(localFlatForward.y, localFlatForward.z) * Mathf.Rad2Deg;
// calculate current roll angle
Vector3 flatRight = Vector3.Cross(Vector3.up, flatForward);
Vector3 localFlatRight = transform.InverseTransformDirection(flatRight);
m_rollDegrees = Mathf.Atan2(localFlatRight.y, localFlatRight.x) * Mathf.Rad2Deg;
}
}