KSP API
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Vessel Class Reference

A Vessel object represents a single vessel. Parts that break off from a vessel become their own Vessels. Vessels that merge via docking become one Vessel. More...

Public Types

enum  Situations {
  Situations.LANDED = 0, Situations.SPLASHED = 1, Situations.PRELAUNCH = 2, Situations.FLYING = 3,
  Situations.SUB_ORBITAL = 4, Situations.ORBITING = 5, Situations.ESCAPING = 6, Situations.DOCKED = 7
}
 The type of Vessel.situation More...
 
enum  State { State.INACTIVE = 0, State.ACTIVE = 1, State.DEAD = 2 }
 

Public Member Functions

 Vessel ()
 
ProtoVessel BackupVessel ()
 
void ChangeWorldVelocity (Vector3d velOffset)
 Add a given velocity offset to the vessels current velocity, instantaneously (may only work for loaded vessels?) More...
 
bool checkLanded ()
 
bool checkSplashed ()
 
bool checkVisibility ()
 
void ClearStaging ()
 
void DespawnCrew ()
 
void DestroyVesselComponents ()
 
void Die ()
 
void FallBackReferenceTransform ()
 
void FeedInputFeed ()
 
VesselType FindDefaultVesselType ()
 
Vector3 findLocalCenterOfMass ()
 
Vector3 findLocalCenterOfPressure ()
 Broken Function with expensive runtime. Do not use. (If it worked it'd do as the name says but it doesn't as of 0.23.5) More...
 
Vector3 findLocalMOI ()
 
Vector3 findLocalMOI (Vector3 worldCoM)
 Returns the vessel's moment of inertia around its center of mass. More...
 
Vector3 findWorldCenterOfMass ()
 Computes and returns the position of the center of mass of the vessel, in world coordinates. More...
 
List< PartGetActiveParts ()
 
int GetCrewCapacity ()
 
int GetCrewCount ()
 The number of kerbals inside the vessel. This is ONLY reliable when the vessel is loaded (vessel.loaded == true). When the vessel is unloaded you can compute the crew count as More...
 
Vector3 GetFwdVector ()
 
float GetHeightFromSurface ()
 
float GetHeightFromTerrain ()
 
string GetName ()
 
Vector3 GetObtVelocity ()
 
Orbit GetOrbit ()
 
OrbitDriver GetOrbitDriver ()
 
Vector3 GetSrfVelocity ()
 
float GetTotalMass ()
 
Transform GetTransform ()
 Gets the transform of the part the vessel is being controlled from (i.e., the part set by the "control from here" right click option). More...
 
Vessel GetVessel ()
 
List< ProtoCrewMember > GetVesselCrew ()
 
Vector3d GetWorldPos3D ()
 
void GoOffRails ()
 Pulls the vessel off rails? More...
 
void GoOnRails ()
 Puts the vessel on rails? More...
 
bool HasControlSources ()
 
void Initialize (bool fromShipAssembly=false)
 
ClearToSaveStatus IsClearToSave ()
 
void Load ()
 
void MakeActive ()
 
void MakeInactive ()
 
void OnDestroy ()
 
void OnLoadFlightState (Dictionary< string, KSPParseable > dataPool)
 
void OnSaveFlightState (Dictionary< string, KSPParseable > dataPool)
 
void printCollisions ()
 
void printGroundContacts ()
 
void RenameVessel ()
 
void ResetCollisionIgnores ()
 
void ResumeStaging ()
 
void SetActiveInternalPart ()
 
void SetActiveInternalPart (List< Part > visibleParts)
 
void SetActiveInternalPart (Part visiblePart)
 
void SetPosition (Vector3 position)
 
void SetPosition (Vector3 position, bool usePristineCoords)
 
void SetReferenceTransform (Part p)
 
void SetReferenceTransform (Transform t)
 
void SetRotation (Quaternion rotation)
 
void SetWorldVelocity (Vector3d vel)
 Sets the velocity of the vessel to a new value, instantaneously. May only work for loaded vessels? More...
 
void SpawnCrew ()
 
void StartFromBackup (ProtoVessel pv)
 
void Translate (Vector3 offset)
 
void Unload ()
 
double RevealAltitude ()
 Returns the vessel's altitude above the reference sphere of the CelestialBody it orbits More...
 
float RevealMass ()
 Returns the vessel's mass, in tons More...
 
string RevealName ()
 Returns the vessel's tracking station name More...
 
string RevealSituationString ()
 Describes the state of the vessel More...
 
double RevealSpeed ()
 Returns the vessel's speed More...
 
string RevealType ()
 Returns the type of the vessel More...
 

Static Public Member Functions

static string GetMETString (Vessel v)
 
static string GetSituationString (Vessel v)
 
static bool IsValidVesselName (string name)
 

Public Attributes

Vector3d acceleration
 Presumably, this is the current acceleration vector of the vessel, in m/s^2? More...
 
double altitude
 Presumably, this is the current altitude above sea of the vessel, in meters? Is equal to pqsAltitude + heightFromTerrain (where heightFromTerrain is not -1). More...
 
Vector3 angularMomentum
 Presumably, this is the current angular momentum of the vessel? More...
 
Vector3 angularVelocity
 The current angular velocity vector of the vessel. More...
 
double atmDensity
 Presumably, this is the current density of the atmosphere at the vessel's position? More...
 
Vector3 CoM
 Presumably, this is the position of the center of mass of the vessel? More...
 
FlightCtrlState ctrlState
 The set of flight inputs currently being fed to the vessel. For example the current throttle being applied to the vesesl is vessel.ctrlState.mainThrottle. More...
 
int currentStage
 Presumably, the current stage of the vessel as seen e.g. in the staging display More...
 
FlightIntegrator flightIntegrator
 
double geeForce
 
double geeForce_immediate
 
float heightFromSurface
 Appears to always be -1? More...
 
float heightFromTerrain
 The vertical distance in meters between the vessel and the nearest terrain (including buildings), or -1 when sea depth is greater than 600m (terrainAltitude <= -600). More...
 
double horizontalSrfSpeed
 Presumably, the horizontal component of srf_velocity, in m/s. More...
 
Guid id
 A unique identifier assigned to a vessel. When two vessels dock, the combined vessel has the id of the vessel docked to. On undock, the vessel undocked from keeps its id, the vessel that undocks gets a new id. Note that this id is always fresh, a vessel gets a different id when it undocks then it had before docking. This is the pid value in the persistent.sfs at the VESSEL level. More...
 
bool isEVA
 Presumably, whether this vessel is an EVAing kerbal. More...
 
bool Landed
 Whether the vessel is currently sitting on the ground. More...
 
string landedAt
 
double latitude
 The current latitude of the vessel over the current mainBody, in degrees. More...
 
double launchTime
 The universal time at which the vessel was launched, in seconds? More...
 
bool loaded
 Whether the vessel is currently loaded. Vessels are only loaded when they come within about 2.5km of the active vessel. More...
 
Vector3 localCoM
 
double longitude
 The current longitude of the vessel over the current mainBody, in degrees More...
 
double missionTime
 Mission elapsed time, in seconds, maybe? More...
 
Vector3 MOI
 
Vector3d obt_velocity
 The current velocity of the vessel, in world coordinates, in the nonrotating inertial reference frame. More...
 
FlightInputCallback OnFlyByWire
 You can add your own function to this callback to register a function that can provide flight control input to the vessel. Once you've registered this callback, it will be called once per FixedUpdate. Provide flight control input by modifying the FlightCtrlState passed to your function. This FlightCtrlState will already contain the player's input, which you can modify or override as desired. More...
 
Callback OnJustAboutToBeDestroyed
 You can add a function to this callback, and the function will be called when the vessel is "just about to be destroyed." More...
 
OrbitDriver orbitDriver
 
OrbitTargeter orbitTargeter
 
bool packed
 Whether the vessel is currently packed. Vessels are only packed when the come within about 300m of the active vessel. More...
 
List< Partparts
 A list of the parts in the vessel. Note that when the vessel is not loaded, this list will be empty. More...
 
PatchedConicRenderer patchedConicRenderer
 
PatchedConicSolver patchedConicSolver
 Among other things, the patchedConicSolver stores information about the player's current set of maneuver nodes. More...
 
Vector3d perturbation
 
double pqsAltitude
 Presumably, the height in meters of the planet's terrain QuadSphere directly under the vessel, compared to sea level. This does not take the height of buildings into account. It is generally within +/- 1m of terrainAltitude, except when over buildings (terrainAltitude does account for buildings) or sea with a depth of greater than 600m (terrainAltitude <= -600, heightFromTerrain == -1). More...
 
ProtoVessel protoVessel
 The protoVessel can be used to get some saved information about unloaded vessels. More...
 
Vector3 rb_velocity
 
uint referenceTransformId
 This is the flightID of the part that is the current 'Control from Here' part. This is the root part until changed by the player. The vessel transform is set to the transform of this part. This is the 'ref' value in the persistent.sfs at the VESSEL level. More...
 
Part rootPart
 The root of the tree of parts that comprises the vessel. Usually this is the original command pod placed when constructing the vessel. More...
 
Vessel.Situations situation
 Some coarse information about the current state of the vessel. More...
 
double specificAcceleration
 
bool Splashed
 Whether the vessel is currently splashed down. More...
 
Vector3d srf_velocity
 The velocity of the vessel in the "surface" reference frame, the reference frame that rotates with the planet. More...
 
Quaternion srfRelRotation
 
Vessel.State state
 
double staticPressure
 Presumably, the atmospheric pressure at the vessel's current location. More...
 
double terrainAltitude
 The height in meters of the nearest terrain (including buildings) directly under the vessel, compared to sea level. Ground which is underwater will have a negative terrainAltitude. More...
 
Vector3 terrainNormal
 
Vector3d upAxis
 Presumably, a unit vector in the up (radially outward from the planet) direction. More...
 
double verticalSpeed
 Presumably, the vertical speed of the vessel in m/s. More...
 
string vesselName
 The name of the vessel as it appears in e.g. the tracking station. More...
 
VesselType vesselType
 The type of the vessel, as shown by the type of icon on the map view. More...
 

Static Public Attributes

static float loadDistance
 
static float unloadDistance
 

Properties

ActionGroupList ActionGroups [get]
 
DiscoveryInfo DiscoveryInfo [get]
 Describes to what extent this object has been explored More...
 
bool HoldPhysics [get]
 
bool isActiveVessel [get]
 Whether the player is currently controlling this vessel. More...
 
bool isCommandable [get]
 
bool IsControllable [get]
 
bool isPersistent [get, set]
 
bool LandedOrSplashed [get]
 Landed || Splashed; use this to determined whether the vessel is on the ground somewhere, whether on land or water. More...
 
CelestialBody mainBody [get]
 The body whose sphere of influence the vessel is currently in. More...
 
Orbit orbit [get]
 The current orbit of the vessel. More...
 
List< PartParts [get]
 A list of the parts this vessel is composed of. More...
 
Transform ReferenceTransform [get]
 
Part this[int index] [get]
 Get a part by its index, in some order. More...
 
Part this[uint flightID] [get]
 Get a part by its part.flightID value More...
 

Detailed Description

A Vessel object represents a single vessel. Parts that break off from a vessel become their own Vessels. Vessels that merge via docking become one Vessel.

Member Enumeration Documentation

The type of Vessel.situation

Enumerator
LANDED 
SPLASHED 
PRELAUNCH 

Waiting on the launchpad, ready to be launched

FLYING 
SUB_ORBITAL 

On a collision course with the ground

ORBITING 
ESCAPING 

On a hyperbolic trajectory

DOCKED 
Enumerator
INACTIVE 
ACTIVE 
DEAD 

Constructor & Destructor Documentation

Vessel.Vessel ( )

Member Function Documentation

ProtoVessel Vessel.BackupVessel ( )
void Vessel.ChangeWorldVelocity ( Vector3d  velOffset)

Add a given velocity offset to the vessels current velocity, instantaneously (may only work for loaded vessels?)

Parameters
velOffset
bool Vessel.checkLanded ( )
bool Vessel.checkSplashed ( )
bool Vessel.checkVisibility ( )
void Vessel.ClearStaging ( )
void Vessel.DespawnCrew ( )
void Vessel.DestroyVesselComponents ( )
void Vessel.Die ( )
void Vessel.FallBackReferenceTransform ( )
void Vessel.FeedInputFeed ( )
VesselType Vessel.FindDefaultVesselType ( )
Vector3 Vessel.findLocalCenterOfMass ( )
Vector3 Vessel.findLocalCenterOfPressure ( )

Broken Function with expensive runtime. Do not use. (If it worked it'd do as the name says but it doesn't as of 0.23.5)

Returns
Vector3 Vessel.findLocalMOI ( )
Vector3 Vessel.findLocalMOI ( Vector3  worldCoM)

Returns the vessel's moment of inertia around its center of mass.

<warning>Returns nonsense answers; DO NOT USE</warning>

Vector3 Vessel.findWorldCenterOfMass ( )

Computes and returns the position of the center of mass of the vessel, in world coordinates.

Returns
List<Part> Vessel.GetActiveParts ( )
int Vessel.GetCrewCapacity ( )
int Vessel.GetCrewCount ( )

The number of kerbals inside the vessel. This is ONLY reliable when the vessel is loaded (vessel.loaded == true). When the vessel is unloaded you can compute the crew count as

vessel.protoVessel.protoPartSnapshots.Sum(pps => pps.protoModuleCrew.Count))

Returns
Vector3 Vessel.GetFwdVector ( )
float Vessel.GetHeightFromSurface ( )
float Vessel.GetHeightFromTerrain ( )
static string Vessel.GetMETString ( Vessel  v)
static
string Vessel.GetName ( )
Vector3 Vessel.GetObtVelocity ( )
Orbit Vessel.GetOrbit ( )
OrbitDriver Vessel.GetOrbitDriver ( )
static string Vessel.GetSituationString ( Vessel  v)
static
Vector3 Vessel.GetSrfVelocity ( )
float Vessel.GetTotalMass ( )
Transform Vessel.GetTransform ( )

Gets the transform of the part the vessel is being controlled from (i.e., the part set by the "control from here" right click option).

Returns
Vessel Vessel.GetVessel ( )
List<ProtoCrewMember> Vessel.GetVesselCrew ( )
Vector3d Vessel.GetWorldPos3D ( )
void Vessel.GoOffRails ( )

Pulls the vessel off rails?

void Vessel.GoOnRails ( )

Puts the vessel on rails?

bool Vessel.HasControlSources ( )
void Vessel.Initialize ( bool  fromShipAssembly = false)
ClearToSaveStatus Vessel.IsClearToSave ( )
static bool Vessel.IsValidVesselName ( string  name)
static
void Vessel.Load ( )
void Vessel.MakeActive ( )
void Vessel.MakeInactive ( )
void Vessel.OnDestroy ( )
void Vessel.OnLoadFlightState ( Dictionary< string, KSPParseable >  dataPool)
void Vessel.OnSaveFlightState ( Dictionary< string, KSPParseable >  dataPool)
void Vessel.printCollisions ( )
void Vessel.printGroundContacts ( )
void Vessel.RenameVessel ( )
void Vessel.ResetCollisionIgnores ( )
void Vessel.ResumeStaging ( )
double Vessel.RevealAltitude ( )

Returns the vessel's altitude above the reference sphere of the CelestialBody it orbits

Implements IDiscoverable

float Vessel.RevealMass ( )

Returns the vessel's mass, in tons

Implements IDiscoverable

string Vessel.RevealName ( )

Returns the vessel's tracking station name

Implements IDiscoverable

string Vessel.RevealSituationString ( )

Describes the state of the vessel

Returns
A string containing the sphere of influence and trajectory of the object

"Orbiting the Sun"

Implements IDiscoverable

double Vessel.RevealSpeed ( )

Returns the vessel's speed

Implements IDiscoverable

string Vessel.RevealType ( )

Returns the type of the vessel

Returns
A string representation of vesselType

Implements IDiscoverable

void Vessel.SetActiveInternalPart ( )
void Vessel.SetActiveInternalPart ( List< Part visibleParts)
void Vessel.SetActiveInternalPart ( Part  visiblePart)
void Vessel.SetPosition ( Vector3  position)
void Vessel.SetPosition ( Vector3  position,
bool  usePristineCoords 
)
void Vessel.SetReferenceTransform ( Part  p)
void Vessel.SetReferenceTransform ( Transform  t)
void Vessel.SetRotation ( Quaternion  rotation)
void Vessel.SetWorldVelocity ( Vector3d  vel)

Sets the velocity of the vessel to a new value, instantaneously. May only work for loaded vessels?

Parameters
vel
void Vessel.SpawnCrew ( )
void Vessel.StartFromBackup ( ProtoVessel  pv)
void Vessel.Translate ( Vector3  offset)
void Vessel.Unload ( )

Member Data Documentation

Vector3d Vessel.acceleration

Presumably, this is the current acceleration vector of the vessel, in m/s^2?

double Vessel.altitude

Presumably, this is the current altitude above sea of the vessel, in meters? Is equal to pqsAltitude + heightFromTerrain (where heightFromTerrain is not -1).

Vector3 Vessel.angularMomentum

Presumably, this is the current angular momentum of the vessel?

Vector3 Vessel.angularVelocity

The current angular velocity vector of the vessel.

double Vessel.atmDensity

Presumably, this is the current density of the atmosphere at the vessel's position?

Vector3 Vessel.CoM

Presumably, this is the position of the center of mass of the vessel?

FlightCtrlState Vessel.ctrlState

The set of flight inputs currently being fed to the vessel. For example the current throttle being applied to the vesesl is vessel.ctrlState.mainThrottle.

int Vessel.currentStage

Presumably, the current stage of the vessel as seen e.g. in the staging display

FlightIntegrator Vessel.flightIntegrator
double Vessel.geeForce
double Vessel.geeForce_immediate
float Vessel.heightFromSurface

Appears to always be -1?

float Vessel.heightFromTerrain

The vertical distance in meters between the vessel and the nearest terrain (including buildings), or -1 when sea depth is greater than 600m (terrainAltitude <= -600).

double Vessel.horizontalSrfSpeed

Presumably, the horizontal component of srf_velocity, in m/s.

Guid Vessel.id

A unique identifier assigned to a vessel. When two vessels dock, the combined vessel has the id of the vessel docked to. On undock, the vessel undocked from keeps its id, the vessel that undocks gets a new id. Note that this id is always fresh, a vessel gets a different id when it undocks then it had before docking. This is the pid value in the persistent.sfs at the VESSEL level.

bool Vessel.isEVA

Presumably, whether this vessel is an EVAing kerbal.

bool Vessel.Landed

Whether the vessel is currently sitting on the ground.

string Vessel.landedAt
double Vessel.latitude

The current latitude of the vessel over the current mainBody, in degrees.

double Vessel.launchTime

The universal time at which the vessel was launched, in seconds?

float Vessel.loadDistance
static
bool Vessel.loaded

Whether the vessel is currently loaded. Vessels are only loaded when they come within about 2.5km of the active vessel.

Vector3 Vessel.localCoM
double Vessel.longitude

The current longitude of the vessel over the current mainBody, in degrees

double Vessel.missionTime

Mission elapsed time, in seconds, maybe?

Vector3 Vessel.MOI
Vector3d Vessel.obt_velocity

The current velocity of the vessel, in world coordinates, in the nonrotating inertial reference frame.

FlightInputCallback Vessel.OnFlyByWire

You can add your own function to this callback to register a function that can provide flight control input to the vessel. Once you've registered this callback, it will be called once per FixedUpdate. Provide flight control input by modifying the FlightCtrlState passed to your function. This FlightCtrlState will already contain the player's input, which you can modify or override as desired.

void MyAutopilotFunction(FlightCtrlState s) { s.yaw = 1; } ... vessel.OnFlyByWire += MyAutopilotFunction This will create an autopilot that always yaws hard to the right. You can probably devise something more useful, though...

Callback Vessel.OnJustAboutToBeDestroyed

You can add a function to this callback, and the function will be called when the vessel is "just about to be destroyed."

OrbitDriver Vessel.orbitDriver
OrbitTargeter Vessel.orbitTargeter
bool Vessel.packed

Whether the vessel is currently packed. Vessels are only packed when the come within about 300m of the active vessel.

List<Part> Vessel.parts

A list of the parts in the vessel. Note that when the vessel is not loaded, this list will be empty.

PatchedConicRenderer Vessel.patchedConicRenderer
PatchedConicSolver Vessel.patchedConicSolver

Among other things, the patchedConicSolver stores information about the player's current set of maneuver nodes.

Vector3d Vessel.perturbation
double Vessel.pqsAltitude

Presumably, the height in meters of the planet's terrain QuadSphere directly under the vessel, compared to sea level. This does not take the height of buildings into account. It is generally within +/- 1m of terrainAltitude, except when over buildings (terrainAltitude does account for buildings) or sea with a depth of greater than 600m (terrainAltitude <= -600, heightFromTerrain == -1).

ProtoVessel Vessel.protoVessel

The protoVessel can be used to get some saved information about unloaded vessels.

Vector3 Vessel.rb_velocity
uint Vessel.referenceTransformId

This is the flightID of the part that is the current 'Control from Here' part. This is the root part until changed by the player. The vessel transform is set to the transform of this part. This is the 'ref' value in the persistent.sfs at the VESSEL level.

Part Vessel.rootPart

The root of the tree of parts that comprises the vessel. Usually this is the original command pod placed when constructing the vessel.

Vessel.Situations Vessel.situation

Some coarse information about the current state of the vessel.

double Vessel.specificAcceleration
bool Vessel.Splashed

Whether the vessel is currently splashed down.

Vector3d Vessel.srf_velocity

The velocity of the vessel in the "surface" reference frame, the reference frame that rotates with the planet.

Quaternion Vessel.srfRelRotation
Vessel.State Vessel.state
double Vessel.staticPressure

Presumably, the atmospheric pressure at the vessel's current location.

double Vessel.terrainAltitude

The height in meters of the nearest terrain (including buildings) directly under the vessel, compared to sea level. Ground which is underwater will have a negative terrainAltitude.

Vector3 Vessel.terrainNormal
float Vessel.unloadDistance
static
Vector3d Vessel.upAxis

Presumably, a unit vector in the up (radially outward from the planet) direction.

double Vessel.verticalSpeed

Presumably, the vertical speed of the vessel in m/s.

string Vessel.vesselName

The name of the vessel as it appears in e.g. the tracking station.

VesselType Vessel.vesselType

The type of the vessel, as shown by the type of icon on the map view.

Property Documentation

ActionGroupList Vessel.ActionGroups
get
DiscoveryInfo Vessel.DiscoveryInfo
get

Describes to what extent this object has been explored

bool Vessel.HoldPhysics
get
bool Vessel.isActiveVessel
get

Whether the player is currently controlling this vessel.

bool Vessel.isCommandable
get
bool Vessel.IsControllable
get
bool Vessel.isPersistent
getset
bool Vessel.LandedOrSplashed
get

Landed || Splashed; use this to determined whether the vessel is on the ground somewhere, whether on land or water.

CelestialBody Vessel.mainBody
get

The body whose sphere of influence the vessel is currently in.

Orbit Vessel.orbit
get

The current orbit of the vessel.

List<Part> Vessel.Parts
get

A list of the parts this vessel is composed of.

Transform Vessel.ReferenceTransform
get
Part Vessel.this[int index]
get

Get a part by its index, in some order.

Parameters
indexIndex of the part to get.
Returns
The "index"th part in the vessel.
Part Vessel.this[uint flightID]
get

Get a part by its part.flightID value

Parameters
flightIDThe flightID value of some part in the vessel
Returns
The matching part, or null if there is no part with that flightID.

The documentation for this class was generated from the following file: