# SpaceCenter¶

public class SpaceCenter

Provides functionality to interact with Kerbal Space Program. This includes controlling the active vessel, managing its resources, planning maneuver nodes and auto-piloting.

float getScience()

The current amount of science.

Game Scenes: All
double getFunds()

The current amount of funds.

Game Scenes: All
float getReputation()

The current amount of reputation.

Game Scenes: All
Vessel getActiveVessel()
void setActiveVessel(Vessel value)

The currently active vessel.

Game Scenes: Flight
java.util.List<Vessel> getVessels()

A list of all the vessels in the game.

Game Scenes: All
java.util.Map<String, CelestialBody> getBodies()

A dictionary of all celestial bodies (planets, moons, etc.) in the game, keyed by the name of the body.

Game Scenes: All
CelestialBody getTargetBody()
void setTargetBody(CelestialBody value)

The currently targeted celestial body.

Game Scenes: Flight
Vessel getTargetVessel()
void setTargetVessel(Vessel value)

The currently targeted vessel.

Game Scenes: Flight
DockingPort getTargetDockingPort()
void setTargetDockingPort(DockingPort value)

The currently targeted docking port.

Game Scenes: Flight
void clearTarget()

Clears the current target.

Game Scenes: Flight
java.util.List<String> launchableVessels(String craftDirectory)

Returns a list of vessels from the given craftDirectory that can be launched.

Parameters: craftDirectory (String) – Name of the directory in the current saves “Ships” directory. For example "VAB" or "SPH". All
void launchVessel(String craftDirectory, String name, String launchSite, boolean recover)

Launch a vessel.

Parameters: craftDirectory (String) – Name of the directory in the current saves “Ships” directory, that contains the craft file. For example "VAB" or "SPH". name (String) – Name of the vessel to launch. This is the name of the “.craft” file in the save directory, without the “.craft” file extension. launchSite (String) – Name of the launch site. For example "LaunchPad" or "Runway". recover (boolean) – If true and there is a vessel on the launch site, recover it before launching. All

Note

Throws an exception if any of the games pre-flight checks fail.

void launchVesselFromVAB(String name, boolean recover)

Launch a new vessel from the VAB onto the launchpad.

Parameters: name (String) – Name of the vessel to launch. recover (boolean) – If true and there is a vessel on the launch pad, recover it before launching. All

Note

This is equivalent to calling launchVessel(String, String, String, boolean) with the craft directory set to “VAB” and the launch site set to “LaunchPad”. Throws an exception if any of the games pre-flight checks fail.

void launchVesselFromSPH(String name, boolean recover)

Launch a new vessel from the SPH onto the runway.

Parameters: name (String) – Name of the vessel to launch. recover (boolean) – If true and there is a vessel on the runway, recover it before launching. All

Note

This is equivalent to calling launchVessel(String, String, String, boolean) with the craft directory set to “SPH” and the launch site set to “Runway”. Throws an exception if any of the games pre-flight checks fail.

void save(String name)

Save the game with a given name. This will create a save file called name.sfs in the folder of the current save game.

Parameters: name (String) – All
void load(String name)

Load the game with the given name. This will create a load a save file called name.sfs from the folder of the current save game.

Parameters: name (String) – All
void quicksave()

Save a quicksave.

Game Scenes: All

Note

This is the same as calling save(String) with the name “quicksave”.

void quickload()

Game Scenes: All

Note

This is the same as calling load(String) with the name “quicksave”.

boolean getUIVisible()
void setUIVisible(boolean value)

Whether the UI is visible.

Game Scenes: Flight
boolean getNavball()
void setNavball(boolean value)

Whether the navball is visible.

Game Scenes: Flight
double getUT()

The current universal time in seconds.

Game Scenes: All
double getG()

The value of the gravitational constant G in $$N(m/kg)^2$$.

Game Scenes: All
float getWarpRate()

The current warp rate. This is the rate at which time is passing for either on-rails or physical time warp. For example, a value of 10 means time is passing 10x faster than normal. Returns 1 if time warp is not active.

Game Scenes: Flight
float getWarpFactor()

The current warp factor. This is the index of the rate at which time is passing for either regular “on-rails” or physical time warp. Returns 0 if time warp is not active. When in on-rails time warp, this is equal to getRailsWarpFactor(), and in physics time warp, this is equal to getPhysicsWarpFactor().

Game Scenes: Flight
int getRailsWarpFactor()
void setRailsWarpFactor(int value)

The time warp rate, using regular “on-rails” time warp. A value between 0 and 7 inclusive. 0 means no time warp. Returns 0 if physical time warp is active.

If requested time warp factor cannot be set, it will be set to the next lowest possible value. For example, if the vessel is too close to a planet. See the KSP wiki for details.

Game Scenes: Flight
int getPhysicsWarpFactor()
void setPhysicsWarpFactor(int value)

The physical time warp rate. A value between 0 and 3 inclusive. 0 means no time warp. Returns 0 if regular “on-rails” time warp is active.

Game Scenes: Flight
boolean canRailsWarpAt(int factor)

Returns true if regular “on-rails” time warp can be used, at the specified warp factor. The maximum time warp rate is limited by various things, including how close the active vessel is to a planet. See the KSP wiki for details.

Parameters: factor (int) – The warp factor to check. Flight
int getMaximumRailsWarpFactor()

The current maximum regular “on-rails” warp factor that can be set. A value between 0 and 7 inclusive. See the KSP wiki for details.

Game Scenes: Flight
void warpTo(double ut, float maxRailsRate, float maxPhysicsRate)

Uses time acceleration to warp forward to a time in the future, specified by universal time ut. This call blocks until the desired time is reached. Uses regular “on-rails” or physical time warp as appropriate. For example, physical time warp is used when the active vessel is traveling through an atmosphere. When using regular “on-rails” time warp, the warp rate is limited by maxRailsRate, and when using physical time warp, the warp rate is limited by maxPhysicsRate.

Parameters: ut (double) – The universal time to warp to, in seconds. maxRailsRate (float) – The maximum warp rate in regular “on-rails” time warp. maxPhysicsRate (float) – The maximum warp rate in physical time warp. When the time warp is complete. Flight
org.javatuples.Triplet<Double, Double, Double> transformPosition(org.javatuples.Triplet<Double, Double, Double> position, ReferenceFrame from, ReferenceFrame to)

Converts a position from one reference frame to another.

Parameters: position (org.javatuples.Triplet) – Position, as a vector, in reference frame from. from (ReferenceFrame) – The reference frame that the position is in. to (ReferenceFrame) – The reference frame to covert the position to. The corresponding position, as a vector, in reference frame to. All
org.javatuples.Triplet<Double, Double, Double> transformDirection(org.javatuples.Triplet<Double, Double, Double> direction, ReferenceFrame from, ReferenceFrame to)

Converts a direction from one reference frame to another.

Parameters: direction (org.javatuples.Triplet) – Direction, as a vector, in reference frame from. from (ReferenceFrame) – The reference frame that the direction is in. to (ReferenceFrame) – The reference frame to covert the direction to. The corresponding direction, as a vector, in reference frame to. All
org.javatuples.Quartet<Double, Double, Double, Double> transformRotation(org.javatuples.Quartet<Double, Double, Double, Double> rotation, ReferenceFrame from, ReferenceFrame to)

Converts a rotation from one reference frame to another.

Parameters: rotation (org.javatuples.Quartet) – Rotation, as a quaternion of the form $$(x, y, z, w)$$, in reference frame from. from (ReferenceFrame) – The reference frame that the rotation is in. to (ReferenceFrame) – The reference frame to covert the rotation to. The corresponding rotation, as a quaternion of the form $$(x, y, z, w)$$, in reference frame to. All
org.javatuples.Triplet<Double, Double, Double> transformVelocity(org.javatuples.Triplet<Double, Double, Double> position, org.javatuples.Triplet<Double, Double, Double> velocity, ReferenceFrame from, ReferenceFrame to)

Converts a velocity (acting at the specified position) from one reference frame to another. The position is required to take the relative angular velocity of the reference frames into account.

Parameters: position (org.javatuples.Triplet) – Position, as a vector, in reference frame from. velocity (org.javatuples.Triplet) – Velocity, as a vector that points in the direction of travel and whose magnitude is the speed in meters per second, in reference frame from. from (ReferenceFrame) – The reference frame that the position and velocity are in. to (ReferenceFrame) – The reference frame to covert the velocity to. The corresponding velocity, as a vector, in reference frame to. All
double raycastDistance(org.javatuples.Triplet<Double, Double, Double> position, org.javatuples.Triplet<Double, Double, Double> direction, ReferenceFrame referenceFrame)

Cast a ray from a given position in a given direction, and return the distance to the hit point. If no hit occurs, returns infinity.

Parameters: position (org.javatuples.Triplet) – Position, as a vector, of the origin of the ray. direction (org.javatuples.Triplet) – Direction of the ray, as a unit vector. referenceFrame (ReferenceFrame) – The reference frame that the position and direction are in. The distance to the hit, in meters, or infinity if there was no hit. All
Part raycastPart(org.javatuples.Triplet<Double, Double, Double> position, org.javatuples.Triplet<Double, Double, Double> direction, ReferenceFrame referenceFrame)

Cast a ray from a given position in a given direction, and return the part that it hits. If no hit occurs, returns null.

Parameters: position (org.javatuples.Triplet) – Position, as a vector, of the origin of the ray. direction (org.javatuples.Triplet) – Direction of the ray, as a unit vector. referenceFrame (ReferenceFrame) – The reference frame that the position and direction are in. The part that was hit or null if there was no hit. Flight
boolean getFARAvailable()

Whether Ferram Aerospace Research is installed.

Game Scenes: All
GameMode getGameMode()

The current mode the game is in.

Game Scenes: All
WarpMode getWarpMode()

The current time warp mode. Returns WarpMode.NONE if time warp is not active, WarpMode.RAILS if regular “on-rails” time warp is active, or WarpMode.PHYSICS if physical time warp is active.

Game Scenes: Flight
Camera getCamera()

An object that can be used to control the camera.

Game Scenes: Flight
WaypointManager getWaypointManager()

The waypoint manager.

Game Scenes: Flight
ContractManager getContractManager()

The contract manager.

Game Scenes: All
public enum GameMode

The game mode. Returned by GameMode

public GameMode SANDBOX

Sandbox mode.

public GameMode CAREER

Career mode.

public GameMode SCIENCE

Science career mode.

public GameMode SCIENCE_SANDBOX

Science sandbox mode.

public GameMode MISSION

Mission mode.

public GameMode MISSION_BUILDER

Mission builder mode.

public GameMode SCENARIO

Scenario mode.

public GameMode SCENARIO_NON_RESUMABLE

Scenario mode that cannot be resumed.

public enum WarpMode

The time warp mode. Returned by WarpMode

public WarpMode RAILS

Time warp is active, and in regular “on-rails” mode.

public WarpMode PHYSICS

Time warp is active, and in physical time warp mode.

public WarpMode NONE

Time warp is not active.