Project

General

Profile

Bug #14194

Navball doesn't follow the kerbal when on EVA

Added by linuxgurugamer 18 days ago.

Status:
New
Priority:
Low
Assignee:
-
Category:
EVA
Target version:
-
Start date:
03/12/2017
% Done:

0%

Version:
Platform:
Windows

Description

This was a "feature" added back in 1.0.5: see the Navball section here:http://wiki.kerbalspaceprogram.com/wiki/1.0.5 .

I've fixed it in EVA Enhancements using the following code:

Transform target;
Vector3 rotationOffset = new Vector3(0f, 0f, 0f);
Quaternion attitudeGimbal;
CelestialBody currentMainBody;
static NavBall nav = FindObjectOfType<KSP.UI.Screens.Flight.NavBall>(); // cache somewhere
private void LateUpdate() {
if (!FlightGlobals.ActiveVessel.isEVA || !settings.evaNavballFollowsKerbal)
return;
currentMainBody = FlightGlobals.currentMainBody;
target = FlightGlobals.ActiveVessel.vesselTransform;
attitudeGimbal = Quaternion.Euler(rotationOffset) * Quaternion.Inverse(target.rotation);
nav.navBall.rotation = attitudeGimbal * Quaternion.LookRotation(Vector3.ProjectOnPlane(currentMainBody.position + (currentMainBody.transform.up * (float)currentMainBody.Radius) - target.position, (target.position - currentMainBody.position).normalized).normalized, (target.position - currentMainBody.position).normalized);
}

And using EVA Enhancements, can now flip between modes.. But really, I don't understand why it was done this way.

Also available in: Atom PDF