Skip to content

Instantly share code, notes, and snippets.

@gomker
Created September 17, 2016 18:50
Show Gist options
  • Save gomker/b67d628a0e386bd07acb909e7000b236 to your computer and use it in GitHub Desktop.
Save gomker/b67d628a0e386bd07acb909e7000b236 to your computer and use it in GitHub Desktop.
True Alt
public double TrueAlt()
{
Vector3 pos= this.part.transform.position; //or this.vessel.GetWorldPos3D()
double ASL = FlightGlobals.getAltitudeAtPos(pos);
if (this.vessel.mainBody.pqsController == null) { return ASL; }
double terrainAlt = this.vessel.pqsAltitude;
if (this.vessel.mainBody.ocean && terrainAltitude <= 0) { return ASL; } //Checks for oceans
return ASL - terrainAlt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment