Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lamont-granquist/b47bd1a121c718c17d98c3c993cd827c to your computer and use it in GitHub Desktop.
Save lamont-granquist/b47bd1a121c718c17d98c3c993cd827c to your computer and use it in GitHub Desktop.
FlightCtrlState ctrlState = base.part.vessel.ctrlState;
inputVector = new Vector3(ignorePitch ? 0f : ctrlState.pitch, ignoreRoll ? 0f : ctrlState.roll, ignoreYaw ? 0f : ctrlState.yaw);
float num = actuatorSpeed * TimeWarp.fixedDeltaTime / ctrlSurfaceRange;
if (!useExponentialSpeed)
{
rotatingControlInput.x = Mathf.MoveTowards(rotatingControlInput.x, inputVector.x, num);
rotatingControlInput.y = Mathf.MoveTowards(rotatingControlInput.y, inputVector.y, num);
rotatingControlInput.z = Mathf.MoveTowards(rotatingControlInput.z, inputVector.z, num);
}
else
{
rotatingControlInput.x = Mathf.Lerp(rotatingControlInput.x, inputVector.x, num);
rotatingControlInput.y = Mathf.Lerp(rotatingControlInput.y, inputVector.y, num);
rotatingControlInput.z = Mathf.Lerp(rotatingControlInput.z, inputVector.z, num);
}
action = Vector3.Dot(rotatingControlInput, zero);
deflection = ctrlSurfaceRange * action * authorityLimiter * 0.01f;
if (deploy)
{
currentDeployAngle = (deployInvert ? (-1f) : 1f) * (partDeployInvert ? (-1f) : 1f) * deployAngle * deflectionDirection;
deflection += currentDeployAngle;
}
deflection = Mathf.Clamp(deflection, -1.5f * ctrlSurfaceRange, 1.5f * ctrlSurfaceRange);
ctrlSurface.localRotation = neutral * Quaternion.AngleAxis(0f - deflection, Vector3.right);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment