Time Warp#
KSP speeds up time in two ways. Rails warp, up to 100,000 times normal, stops simulating the vessel’s physics and moves it along its orbit. Physics warp, up to 4 times normal, runs the physics simulation faster, so the vessel still flies under its own power. This guide describes how to use both from a script.
Warping to a Time#
SpaceCenter.WarpTo warps until a universal time, then stops. This example warps to ten seconds
before the vessel reaches apoapsis:
apoapsis_ut = space_center.ut + vessel.orbit.time_to_apoapsis
space_center.warp_to(apoapsis_ut - 10)
var apoapsisUT = spaceCenter.UT + vessel.Orbit.TimeToApoapsis;
spaceCenter.WarpTo (apoapsisUT - 10);
auto apoapsis_ut = space_center.ut() + vessel.orbit().time_to_apoapsis();
space_center.warp_to(apoapsis_ut - 10);
double ut, time_to_apoapsis;
krpc_SpaceCenter_Orbit_t orbit;
krpc_SpaceCenter_UT(conn, &ut);
krpc_SpaceCenter_Vessel_Orbit(conn, &orbit, vessel);
krpc_SpaceCenter_Orbit_TimeToApoapsis(conn, &time_to_apoapsis, orbit);
double apoapsis_ut = ut + time_to_apoapsis;
krpc_SpaceCenter_WarpTo(conn, apoapsis_ut - 10, 100000, 2);
double apoapsisUT =
spaceCenter.getUT() + vessel.getOrbit().getTimeToApoapsis();
spaceCenter.warpTo(apoapsisUT - 10, 100000, 2);
local apoapsis_ut = space_center.ut + vessel.orbit.time_to_apoapsis
space_center.warp_to(apoapsis_ut - 10)
const orbit = await vessel.getOrbit();
const apoapsisUT =
(await spaceCenter.getUT()) + (await orbit.getTimeToApoapsis());
await spaceCenter.warpTo(apoapsisUT - 10);
The call returns once the time is reached. It uses rails warp when the game allows it, and physics warp otherwise, such as in an atmosphere. It slows the warp as the time approaches, and arrives close to it rather than exactly on it. Warp to a few seconds before an event you need to act on, such as a burn.
Its two optional arguments cap the rate: maxRailsRate for rails warp, 100,000 by default, and
maxPhysicsRate for physics warp, 2 by default.
WarpTo takes many physics ticks, so it ends any hold on the tick that your client has. It raises an exception if the game scene
changes during the warp. A server side function cannot call it.
Warp Factors#
A warp factor is the position of the warp rate on the game’s warp control, not the rate itself.
SpaceCenter.RailsWarpFactor sets rails warp, from 0 to 7, and
SpaceCenter.PhysicsWarpFactor sets physics warp, from 0 to 3. Zero stops warping. This
example prints the highest rails warp factor the game allows now, then sets rails warp to 3:
print(space_center.maximum_rails_warp_factor)
space_center.rails_warp_factor = 3
Console.WriteLine (spaceCenter.MaximumRailsWarpFactor);
spaceCenter.RailsWarpFactor = 3;
std::cout << space_center.maximum_rails_warp_factor() << std::endl;
space_center.set_rails_warp_factor(3);
int32_t maximum;
krpc_SpaceCenter_MaximumRailsWarpFactor(conn, &maximum);
printf("%d\n", (int)maximum);
krpc_SpaceCenter_set_RailsWarpFactor(conn, 3);
System.out.println(spaceCenter.getMaximumRailsWarpFactor());
spaceCenter.setRailsWarpFactor(3);
print(space_center.maximum_rails_warp_factor)
space_center.rails_warp_factor = 3
console.log(await spaceCenter.getMaximumRailsWarpFactor());
await spaceCenter.setRailsWarpFactor(3);
Setting one kind of warp stops the other. A factor above the highest the game allows is lowered to
it, with no exception. SpaceCenter.WarpMode gives the kind of warp in use, and
SpaceCenter.WarpRate the rate, which is 1 when time passes normally. The game eases the rate
toward a new factor over about a second of game time, so WarpRate lags behind a change.
Limits on Rails Warp#
In flight, the game limits rails warp to keep the vessel safe.
SpaceCenter.MaximumRailsWarpFactor gives the highest factor it allows now, and
SpaceCenter.CanRailsWarpAt whether it allows a given factor.
There is no rails warp in an atmosphere, or under high acceleration.
A landed vessel cannot rails warp while it moves.
Close to a body, each factor needs a minimum altitude. The game skips these limits when the vessel’s periapsis is clear of the atmosphere and the terrain, as it does for the player.
A vessel in flight cannot rails warp with its throttle open, unless it is landed. Setting
RailsWarpFactorin flight closes the throttle first.
In the space center and the tracking station, every rails warp factor is allowed. Physics warp works in flight only.
During rails warp, the vessel is packed: the game stops simulating its physics and moves it
along its orbit. Vessel.Packed gives whether a vessel is packed.