Jump to content

The Speed of Ground - A study into how KSP terrain colliders handle land vehicles with high magnitudes of velocity.


Stratzenblitz75

Recommended Posts

Greetings!

If you’ve ever tried to build a landspeeder and tried to set a landspeed record at Kerbin’s poles, you may have run across a strange bug. For whatever reason, you simply cannot get your craft to go above a certain velocity. It just sinks into the ground and explodes as if the terrain colliders simply ceased to exist.

Even stranger, it appears that the speed at which the bug occurs is related to the acceleration of the craft. The land speeder above can reach 1808 m/s at full throttle, but at 50% thrust limiter, it fails at ~1600 m/s.

HJE7lva.png

So what is going on here?

Curious, I devised an experiment to see if there was some sort of predictable relationship between acceleration, final speed, and distance traveled.

Here is what I came up with:

  1. Hyper edit THIS CRAFT (which for the purposes of this report, we will call “Craft 1”) to 40 W and 80 N (These coordinates do not have a special purpose; they simply give plenty of room on the north pole to perform the experiment)
  2. Remove Atmosphere with hyper-edit
  3. Enable infinite fuel (For constant acceleration)
  4. zyaFl2Q.png
  5. Detach Beacon
  6. Quicksave
  7. Quickload
  8. Set Thrust Limiter to 100
  9. Engage full throttle and ignite engine
  10. Pause the moment the camera clips through the surface (You can rapidly pause-unpause the game to do this. I found that this does not affect the speed at which the bug occurs)
  11. Record velocity and distance from beacon in a table
  12. 4X2Ouw1.png
  13. Repeat steps 7 through 12, decreasing the thrust limiter by 5 each time (thrust limiter = [95, 90, 85, etc.])
  14. Calculate the acceleration for each entry using the thrust and mass of the craft
  15. Calculate the time elapsed for each entry using the distance traveled and acceleration

Here are the results of my experiment:

A1Zi4hK.png
 

d2jSSwK.png


tC01r4a.png

Very interesting. It appears that the speed at which the bug occurs IS affected by acceleration. In fact, looking at the graph of distance vs. time, we get something that looks strikingly linear. If we take the equation of the trend line of that graph,

y = 683.83x + 4367.8

solve these kinematic distance equations for the final velocity,

d = (1/2)*(vi + vf)*(t)

d = 683.83t + 4367.8

(1/2)*(0 + vf)*(t) = 683.83t + 4367.8

vf = (1367.66t + 8735.6)/(t)

and take the limit as ‘t’ approaches infinity,

lim t->INF (1367.66t + 8735.6)/(t) = 1367.66

we get a speed of 1368 m/s.

 

This suggests that a craft traveling at a constant velocity above 1368 m/s will encounter the bug, while a craft below this speed will not.

To test this prediction, I simply took the previous craft and accelerated it up to speeds ranging from 1350 to 1400 m/s. Then, I checked if the craft encountered the bug or not.

Here are my results:

Speed Bug? (T/F)
1350 F
1360 F
1376 F
1380 F
1381 F
1382 T
1385 T
1390 T
1400 T

This data shows that my estimate of 1368 m/s is very close to the actual value. The real limit appears to be 1381 m/s. Below this speed, it does not encounter the bug at all. Once a higher speed is reached, it encounters the bug within 5 seconds, but not immediately.

So, once a craft reaches a speed above 1381 m/s and remains at that speed for a certain amount of time, terrain colliders cease to exist. For curiosity’s sake, is it possible to go past this speed, and then slow down and have the colliders come back?

To test this, I built this thing and set it off.

98FYlO0.png

And there you have it. Once the craft slows down to 1380.8 m/s, the terrain colliders instantly come back and shred it to pieces.

What happens if we vary the frame-rate? Do we still get the same results?

To test this, I built a new craft, which we will call “Craft 2,” with rings of inward facing seperatrons. When firing, they tank my framerate to 10 FPS.

gj1dOqR.png

Then, I repeated the above procedure with and without firing the seperatrons.

Here are the results.

AWyYvLx.png

From this, it appears framerate does not have an effect on the final velocity of the craft. Note the differences between Craft 1 and Craft 2 are likely due to the fact that I launched them at different headings (270 and 120 degrees respectively). More on that later.

Alright, so it appears that something is going on at 1381 m/s, but what exactly? The game doesn’t instantly stop reading collisions after this speed, since a speeder can go much faster.

What if the game loads a “radius” of terrain colliders around the craft, and after 1381 m/s, the game stops loading new colliders? This would explain why a craft at a constant velocity encounters the bug 5 or so seconds after reaching 1381 m/s, rather than immediately.

Using this kinematic equation, we can find the distance traveled by the craft from 1381 m/s to the speed at which the bug occurs. From these distances, we will be able to calculate the radius of the terrain colliders.

yZg7ABr.png

Here are the results from applying this calculation to all of our data entries:

H017O7s.png

So the data seems to be scattered around ~7.4 km, with the variation from the lowest and highest value being about 2.5 km. Since all the distances are similar, despite the acceleration, it seems that KSP does STOP loading new colliders after 1381 m/s completely, leaving just a 7.4 km radius of colliders left to travel on.

But why does it vary by 2.5 km?

This could make sense if we consider that KSP does not load terrain continuously, but rather, loads it in chunks. Would this explain the variation?

JFucsmt.png

In an ideal KSP, the distance from the craft to the boundary of the terrain colliders should be constant. However, KSP likely does NOT load terrain continuously like that. Rather, it loads it in square chunks. In such a system the distance from the craft to the boundary can vary depending on direction and distance traveled.

 

If this assumption is correct, then it should be possible to map out one of these terrain chunks by slightly changing the angle at which the craft is launched at and measuring the final distance.

So, I did just that. First, I tested headings from 80 degrees to 100 degrees in increments of 2. Then, I converted the results from polar to Cartesian coordinates. Here are my results:

wRcScT4.png

Hmmm, it looks like a corner of a square. In fact, if you multiply the slopes of the trend lines, you get a value very close to -1, which shows that the edges are perpendicular.

1.183*(-0.8245) = -0.9753835

So indeed, KSP does load terrain in square chunks.

 

Alright, now let’s take ALL the data gathered from this experiment, and apply the kinematic equations from above.

Here is a plot of that operation.

PS4U7R6.png

 

In conclusion, this study shows that KSP loads terrain colliders in squares, and completely stops loading new colliders after reaching 1381 m/s. Effectively, this means that once a land-speeder passes 1381 m/s, it only has between 6 km and 9 km (depending on the direction and distance traveled) to hit the land-speed record before falling off the remaining colliders.

But, why does the game stop loading new colliders after 1381 m/s? My theory is that the devs coded a limit into how fast the terrain loaded in an attempt to optimize the game. After all, why load terrain colliders past this speed if a collision at these speeds would almost always guarantee death anyways? If any KSP devs would like to comment on this, it would be greatly appreciated!

Comments? I’d love to hear your thoughts on this as well.

Also, feel free to download my test craft and perform my experiments. I have not tested this on other computers, so I’m curious if that would make a difference. Just be sure to conduct them on a STOCK INSTALL with only hyperedit and KER. This is because I've found that some mods such as kopernicus change the way the terrain colliders are loaded.

Bye everyone!

-Stratzenblitz

Link to comment
Share on other sites

Wow. Just wow.

Truly shows the hard work and dedication you put into each video! And I love how the scientific method has translated into the game world, and how you use it to find out what's going on.

You've went from sinking into the ground when doing record attempts, to figuring out how KSP loads the collision boxes of planets. Well done! :D

Link to comment
Share on other sites

21 minutes ago, MiffedStarfish said:

Brilliant work! Do you know if this collider unloading effects other craft within load range, or if colliders are loaded separately for different craft? Because I'm having ideas for a new type of stock weapon...

Not sure, haven't tested it. That is an excellent suggestion though. I'll test it as soon as I can!

Link to comment
Share on other sites

Very interesting indeed and I like your approach.

Instead of terrain colliders, there's something else in KSP that boggles me and that's collider collisions between separate entities, they seem partly or primarily based on the mass of a part coupled with its speed, making reliable engines at a small scale a problem. If you like to know more, I'll send you a PM.

Link to comment
Share on other sites

I like this paper, very much actually.

 

So here's some number crunching:

Kerbin's siderial rotational velocity is nearly 175m/s. Now, let's consider the original 1365m/s which were postulated by @Stratzenblitz75 et.al. and substract the surface speed. Substracting the rotational speed of Kerbin from the maximum loading speed, we obtain a difference of 1191m/s. If we take those measured 1381m/s we get a maximum speed of 1207m/s.

Postulating a constant speed at which the physics engine stops calculating the colliders it sounds reasonable that 1200m/s plus the siderial rotational velocity of the body under question might be the math behind this phenomenon. If this hypothesis is true, then other celestial bodies should yield different maximum collider speeds. In any case 1200m/s plus Kerbins siderial rotational velocity is close enough to the value @Stratzenblitz75 et.al provided (1375m/s vs 1381m/s) to test this hypothesis on Minmus. The flats there should yield enough space to perform similar maneuvers. With a siderial rotatonal velocity of just over 9m/s, the maximum speed should yield values around 1210m/s.

 

Link to comment
Share on other sites

13 minutes ago, cubinator said:

[Insert File Select- Super Mario 64]

That's interesting! Is it possible to test this on different planets, or is Kerbin the only place with that much flat ground?

Yes! Indeed it is possible. I've tried this on laythe and minmus and got some interesting results as well. It seems that the speed at which the bug occurs is slower on laythe, and even slower on minmus. This would make sense since the collider squares would be smaller. That said, I'd need to do more experiments; my results on these planets are not conclusive. 

2 hours ago, MatterBeam said:

Incredible work!

Do you have an idea of how Kopernicus changes the way colliders load?

No idea what Kopernicus is doing, but it VASTLY increases the top speed. You can easily get up 3 km/s with Kopernicus installed. It seems as if kopernicus removes the 1381 m/s limit completely.

Link to comment
Share on other sites

4 minutes ago, Stratzenblitz75 said:

Yes! Indeed it is possible. I've tried this on laythe and minmus and got some interesting results as well. It seems that the speed at which the bug occurs is slower on laythe, and even slower on minmus. This would make sense since the collider squares would be smaller. That said, I'd need to do more experiments; my results on these planets are not conclusive. 

1210m/s on Minmus (see above)

1259m/s on Laythe, according to my hypothesis.

If the collider's size was subject to the planet's size then the colliders probably wouldn't be squares or rectangles but have another shape since the planet is a sphere. In my opinion the size is set as a hard value which does not change. However, the surface of the planet is rendered locally, so you never have to worry about overlapping squares or other shapes. You're moving on a local tangential plane, so to speak.

Edited by something
Link to comment
Share on other sites

26 minutes ago, something said:

Kerbin's siderial rotational velocity is nearly 175m/s....

only at the equator.  At the pole, where most of this testing was done, rotational velocity is something close to zero.  Regardless, it's non-constant at varying latitudes so it seems unlikely to work the way you postulate.

Link to comment
Share on other sites

1 hour ago, fourfa said:

only at the equator.  At the pole, where most of this testing was done, rotational velocity is something close to zero.  Regardless, it's non-constant at varying latitudes so it seems unlikely to work the way you postulate.

There will still be some velocity, and it is a very testable hypothesis. I wonder if there are any planets with smooth surfaces at both equator and poles. 

Link to comment
Share on other sites

Nah, I was thinking, that the devs were too lazy and simply implemented a 1200m/s plus worst case offset maximum collider speed. After all, KSP was meant to goto space, not to race on the poles at mach 4 ;) so likely they thought that nobody needed ground colliders at those speeds...

Link to comment
Share on other sites

21 hours ago, MiffedStarfish said:

Brilliant work! Do you know if this collider unloading effects other craft within load range, or if colliders are loaded separately for different craft? Because I'm having ideas for a new type of stock weapon...

Okay, I've conducted some tests and unfortunately, the other craft does not seem to be affected. HOWEVER, I could only get with 1000 m of the craft due to my lack of guidance skill. As a result, while it was loading the craft, it was freezing it in place. If I could get within 200 m (Which, I think is the distance where it unfreezes a craft touching the ground), we could determine this conclusively.

19 hours ago, something said:

1210m/s on Minmus (see above)

1259m/s on Laythe, according to my hypothesis.

If the collider's size was subject to the planet's size then the colliders probably wouldn't be squares or rectangles but have another shape since the planet is a sphere. In my opinion the size is set as a hard value which does not change. However, the surface of the planet is rendered locally, so you never have to worry about overlapping squares or other shapes. You're moving on a local tangential plane, so to speak.

You might be onto something with this. Unfortunately, I did not gather enough data to support any conclusions.

Literally, this is all I got:

 

--- Laythe ---

Mass: 27900

Thrust: 4000

Acceleration: 143.369

HDG Velocity Distance Time
0 1757.5 10800 12.2744
90 1683.5 9900 11.7518
180 1777.3 11100 12.4437
270 1689.5 10000 11.811

 

--- Minmus ---

Mass: 36045 (Extra mass for downforce thrusters)

Thrust: 4000

Acceleration: 110.972

HDG Velocity Distance Time
212 1579 11200 14.2075
231 1637.3 12000 14.7061
250 1630.3 11900 14.6447
270 1585.4 11200 14.2075

 

As you can see, I just tested various headings to get a general idea of how the terrain collider's behaved on these planets.

If you compare the acceleration vs. final velocity of these runs, to the runs conducted on Kerbin, you see that the top speed on Laythe and Minmus is slower:

Acceleration Kerbin Laythe Minmus
143.369 1922.1 1777.3 NA
~110 ~1870 NA 1637.3

 

Not sure if you can draw any more conclusions from this, but you are welcome to try.

I'll go perform some more rigorous tests and get back to you.

21 hours ago, Azimech said:

Very interesting indeed and I like your approach.

Instead of terrain colliders, there's something else in KSP that boggles me and that's collider collisions between separate entities, they seem partly or primarily based on the mass of a part coupled with its speed, making reliable engines at a small scale a problem. If you like to know more, I'll send you a PM.

Do tell! I haven't done much experimenting with part-to-part collisions so I'd love to know more.

Link to comment
Share on other sites

23 hours ago, something said:

1210m/s on Minmus (see above)

1259m/s on Laythe, according to my hypothesis.

If the collider's size was subject to the planet's size then the colliders probably wouldn't be squares or rectangles but have another shape since the planet is a sphere. In my opinion the size is set as a hard value which does not change. However, the surface of the planet is rendered locally, so you never have to worry about overlapping squares or other shapes. You're moving on a local tangential plane, so to speak.

 

Alright, the results are in for Laythe and Minmus!

I simply repeated my first procedure for both of these planets.

For Minmus, I had to build a new craft with downforce thrusters in order to keep it from flying off the terrain. However, the mass and acceleration is the same.

Here are my results as compared to Kerbin:

Li03T4t.png

Applying the limit calculation, we find the speed at which new terrain colliders stop loading are:

For Laythe: 1,148.34 m/s

For Minmus: 1,103.12 m/s

 

Very interesting... It seems that the speed is similar for both Laythe and Minmus, but not quite the same. They are both over 200 m/s slower than on Kerbin.

Any ideas on why this could be? 

 

1 hour ago, monophonic said:

snip

 

Interesting! Although, that post was over 4 years ago. I wonder, have the terrain colliders changed since then?

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...