Jump to content

How does KSP work?


Hyomoto

Recommended Posts

This is sort of a strange question that I think someone who has been around a while might be able to answer (or the developers I suppose if they are bored). Through bits and pieces from scattered sources it seems that KSP works not by moving the player around the universe, but moving the universe around the player. Things like the planets are low resolution models that are scaled into their larger forms as you get closer. This is apparently why on the map for instance if you get really close to a planet you just go inside of it, but if you land on a planet obviously you must get far closer before you can 'peak beneath the surface' so to speak.

What I'd like to know though is what is actually happening? Is there anyone in the community that can explain the basic premise behind the KSP engine and how it handles the planetary transitions? Speculation is fine I suppose, but I'm hoping to hear from someone who has been around enough that they can answer outright.

Link to comment
Share on other sites

Well, in a sense, yes, but no. The universe "exists", but only when you get near certain objects do they load their high-resolution. Altitude is still relative to the body you're around, and is your orbit. The only thing that is moving around your ship is the camera. Everything else is "fixed' or on rails, and your ship is the same, except that it can change that rail every once and a while.

When landed at Kerbin this is obvious; since Kerbin rotates and revolves around Sol it can't be moving the engine around you; it would be so hard on rover physics. Your craft is a little moveable thing, the planets are massive and immobile, relative.

Link to comment
Share on other sites

I was under the impression that the 'kraken' was caused by numbers becoming too large which made the math unwieldy, sort of like Minecraft when you got beyond 30 million blocks or so the world started to behave strangely due to errors in the floating point calculations. I thought I'd heard somewhere that to 'fix' that issue, they basically made it so the universe revolves around the player rather than vice versa. I must have been mistaken but can you clear up where I got this confused?

Link to comment
Share on other sites

Well, in a sense, yes, but no. The universe "exists", but only when you get near certain objects do they load their high-resolution. Altitude is still relative to the body you're around, and is your orbit. The only thing that is moving around your ship is the camera. Everything else is "fixed' or on rails, and your ship is the same, except that it can change that rail every once and a while.

When landed at Kerbin this is obvious; since Kerbin rotates and revolves around Sol it can't be moving the engine around you; it would be so hard on rover physics. Your craft is a little moveable thing, the planets are massive and immobile, relative.

Harvester and the devs have already confirmed that they made the universe move while player is stationary.

I watched them explain this on one of the early KSPTV streams myself.

Link to comment
Share on other sites

IIRC, while moving through the "space" in any SoI, the game will intermittantly set the vessel location to the orgin, and use a unit scale appropriate to the frame (based on location and speed). The vessel will move within this fixed frame away from the origin, and when it moves far enough away from the origin, the game will reset the same focused on the vessels new location.

The origin of this frame is defined in relation to some point of the SoI (presumably, it's center).

Whenever a SoI transition is made, its either Parent -> Child or Child->Parent. So when SoI transitions are made, the location in the new SoI is calcuated as the sum of the following vectors:

  • Offset between parent & child SoI's
  • Offset between frame & SoI
  • Location of vessel in frame

And then, I would assume, it calculates the new location in the new SoI based on the vessel's velocity in the previously rendered scene.

I may be wrong on some of the details, but, overall, I think that's the super simple nuts and bolts.

Link to comment
Share on other sites

Harvester and the devs have already confirmed that they made the universe move while player is stationary.

I watched them explain this on one of the early KSPTV streams myself.

I'm pretty sure this is incorrect. The center of the "universe" will occassionally change, but is then fixed until the next change. Moving the entire universe around a stationary player entity just isn't how Unity works.

Link to comment
Share on other sites

I'm reasonably certain LethalDose has the right of it. The floating origin system will move the universe around the player, but apart from edge cases (e.g., very high velocities) it will almost always leave the reference fixed in place until the craft moves a predetermined distance from the origin. While it is probably possible to move the entire universe every frame (since all but the focused objects and/or nearby craft are running the "on-rails" simplified simulation), I can't help but think it would be entirely unnecessary to do so.

Link to comment
Share on other sites

I also second LethalDose. I've actually employed the same tactic (which I nicknamed the "Futurama Drive") in a few little thingies I've made in my spare time, and it's actually rather easy to do with Unity - just have a script that runs periodically that changes all the positions of the objects in the scene so that the player is centered on (0, 0, 0).

Link to comment
Share on other sites

Kraken issues happen when, like others have said, your craft (which is a collection of connected parts, not a monolithic object) gets too far from the origin or travels too quickly and runs into floating-point errors. The krakensbane system periodically resets the coordinate origin (which correspondingly offsets everything else in the universe) to the player's location when you pass a certain distance threshold. It also "absorbs" the player's velocity relative to the origin when it exceeds a certain velocity threshold, and passes that velocity off to everything else. Basically you're dragging the origin behind you as you fly around the system.

Link to comment
Share on other sites

It's actually a hybrid. If you go slowly enough to not cause rounding errors, your ship moves. If you go above that, it "off-loads" some of the velocity to the universe. It's a much higher limit, but if both the universe and your ship are going fast enough to cause errors, the old kraken will be back with a vengeance. I think this can sometimes be caused by the Hell Kraken glitch, as it causes your ship when you reload to break apart, presumably from good old rounding error kraken forces.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...