Jump to content

How does KSP's water physics work?


Recommended Posts

I'm trying to understand how KSP's water physics work, so I can build nice floaty things without simply spamming radial intakes. So far, all I'm finding is that it's screwy.

Here are some tests I've done using some simple craft. All fuel tanks are empty. The craft with 2 400 tanks is exactly twice the mass and twice the length of the one with a single 400 tank, therefore I would expect it to float with the same fraction of its length below the waterline, as long as the visible water lines up with the physical water. The craft with the 800 tank is the same as the one with 2 400 tanks except for changing the tanks, therefore I would expect it to float identically, even if the visible water and physical water are consistently misaligned.

Instead, I get these results.

[table]

[tr]

[td]14220846259_6d9e92c15b_n.jpg

Low Detail, 400 tank by cantab314, on Flickr[/td]

[td]14384364586_5240a5c33a_n.jpg

Low Detail, 2x 400 tanks by cantab314, on Flickr[/td]

[td]14406176892_c2483bf899_n.jpg

Low Detail, 800 tank by cantab314, on Flickr[/td]

[/tr]

[tr]

[td]14220890790_705b611ff9_n.jpg

Medium Detail, 400 tank by cantab314, on Flickr[/td]

[td]14220841429_6f28b66d12_n.jpg

Medium Detail, 2x 400 tanks by cantab314, on Flickr[/td]

[td]14220842409_ce1248f478_n.jpg

Medium Detail, 800 tank by cantab314, on Flickr[/td]

[/tr]

[tr]

[td]14404127041_6bc41da329_n.jpg

High Detail, 400 tank by cantab314, on Flickr[/td]

[td]14220885870_ac6e4d9564_n.jpg

High Detail, 2x 400 tanks by cantab314, on Flickr[/td]

[td]14404124671_576220ba9d_n.jpg

High Detail, 800 tank by cantab314, on Flickr[/td]

[/tr]

[/table]

I don't know what to make of these really. Low terrain detail seems to throw the visible water level, which I somewhat expected. More baffling is that an 800 tank has different buoyancy properties to a pair of 400 tanks.

I've looked in the part.cfg's for anything that might hint at buoyancy, hypothesising that maybe part scaling throws things off, but the 400 and 800 tanks differ only in name, node positions, tech tree position and cost, description, mass, and fuel and oxizider capacity - in short, nothing that I can see that would make the pair of 400 tanks float higher than the single 800 one.

So what's going on? How exactly does KSP work out part buoyancy?

Link to comment
Share on other sites

Yeah, I've been wondering this too. The only (vague) conclusion I've been able to draw is that "water physics" are only applied to parts that are directly in contact with the water. IE, parts connected to parts touching the water are essentially ignored unless they are also touching the water. This hypothesis would be strengthened if your two craft have the same waterline when on their side, so that both tanks in the 2x400 ship are in contact with the water.

But that's just my empirical musing.

Link to comment
Share on other sites

Water physics is really, really bad at the moment.

In KSP water is an extremely dense fluid, and each parts tends to float (exept for full jumbo tanks and similar ultra heavy object). Intakes are very light and they have a very high water line. The game calculate the floating line without considering that clipped parts subtract volume, so your packed intakes are have an enormous volume for the game physics, and this, combined with their minimal mass, makes your intakes to be a perfect float.

The water physics makes also splashing more dangerous than landing. Instead of increasing your crash tollerance, if you came in hard the parts that collide with water just explode without reducing your speed (instead this happens on solid ground), so "lithobraking" landers don't work in water.

Link to comment
Share on other sites

In KSP water is an extremely dense fluid,

Don't think of it as a fluid, but a surface that produces buoyancy-like forces. Girders are the best for making "buoyant" structures in my experience- my Eve Oceans Explorer has an internal I-beam structure, that lifts its waterline significantly.

Link to comment
Share on other sites

In addition to the above regarding floating, drag when moving sideways in water (for building boats) is just the same drag you would get from stock aerodynamics multiplied by some number. That's why intakes work so well, they have no ordinary drag and instead get drag applied to them from the intake air code which does not care about water.

In effect, radial intakes are almost without drag in water, have an impact tolerance of 70m/s or something, and if you mount them in a row they even kinda look like a float.

Wings work also because they have their own drag code that doesn't care about water, but they have a crash tolerance of about 10m/s or so. Crash tolerance is only checked when something enters the water and rarely when it leaves. So if you avoid that you can use wings instead of intakes. They have more volume, so you can do with less.

At least I think that's how it works.

I don't care if or when squad does something to the water. Aerodynamics yes, but water, I could live with it as it is now...

Not to say I wouldn't immediately download "MysteryPersons Hydrospace Research" :P

Edit: I just remembered, I think buoyancy calculation based on the internal volume of the colliding geometry is a feature of the unity engine you can use out of the box. Maybe that's whats going on here... It does not really explain why two small tanks float better than one large tank though Oo

Edited by the_bT
Link to comment
Share on other sites

I tried allmhuran's experiment (placing the craft flat), and the one with the single 800 tank naturally floated slightly lower at the tank end, while the one with 2 400 tanks floated level and maybe a shade higher. The discrepancy was small, but noticeable. I did it with default/medium terrain detail.

Subsequently, I've run experiments using a common "pontoon" and varying loads on top of it., which have determined, in line with what Tw1 said, that water in KSP doesn't provide a normal buoyancy force. Doubling the weight of a ship considerably less than doubles the amount of water it displaces, contrary to reality. I still need to chart up the results and see if I can figure out a formula to model it.

Link to comment
Share on other sites

How it works?

It doesn't

Seriously though the reason you see different water legals on different detail distances is because with a lower detail setting fewer polygons are used to draw the ocean. If you hack your config you can sometimes see crafts that float in the air without touching the water.

Link to comment
Share on other sites

Indeed, that's a major confounding factor.

My latest results, as I reported previously, may be getting me somewhere. Here's the basic "oil rig" design:

14472343971_6787cec246_o.png

I made versions with various loads on the top and threw them into the water, then took screenshots and measured the percentage of the length of the FL-T800's that was submerged. Graphing my results, I get the following:

14476093615_77705727fc_o.png

A linear relationship with an offset gives a good fit. I experimented with things like power laws, but was not able to improve on the simple, and physically expected, straight line.

From this, and my previous results, I'm prepared to make some hypotheses:

* An object with negligible weight will float with half its volume submerged, with possible small offsets from that due to terrain detail. This is physically incorrect.

* An object will displace additional volume in proportion to the weight on it. This is physically correct.

The other key observation made is that the float depths do not depend on whether the fuel is in the tank on top or the float tanks themselves. The weight gets counted where-ever it is, as is physically correct.

Full "data": https://www.flickr.com/photos/52548818@N05/sets/72157644731171337/

The next factor to investigate is whether, with our hypothesis that massless = float half-submerged, the buoyancy force depends simply on the extra volume of water displaced or whether there are part-specific factors.

Edited by cantab
typo correction
Link to comment
Share on other sites

  • 2 weeks later...

More SCIENCE!

So I did some more runs using a similar setup, with the slight tweak that I dumped fuel (using TAC Fuel Balancer) to change the "oil rig" masses. In addition to the FL-T800, I also tested the FL-T400 and the BACC. As ever, my "raw data" (ie screenshots) are in the Flickr album.

Firstly, graphing the new data as we graphed the previous set, we back up our previous hypothesis: For a given part the relation between percentage underwater and mass on the part is linear, and extrapolates back to around 50% at zero mass. Note that I did remove an outlier from each of the FL-T400 and BACC data sets, in both cases the lowest mass value.

14538744325_901b74304c_o.png

Float Test 3 Graph 1 by cantab314, on Flickr

Secondly, I plotted the absolute volume displaced vs the mass, on a per tank basis (so dividing both quantities by 4 for these tests). The volume displaced was calculated from the diameter and length of the tanks, assuming they are cylinders.

14352348187_72c805a688_o.png

Float Test 3, Graph 2 by cantab314, on Flickr

The key result here is that the lines do not all have the same gradient. This means that the amount of water a given mass displaces in KSP depends on the part doing the displacing.

A third graph instead plots only the excess volume displaced over and above the 50% that's always underwater, in this case leaving the outliers in. The different gradients between the three parts tested are more striking. https://flic.kr/p/obw3H2

In conclusion, whatever KSP is doing, it's very unlike physically correct buoyancy and I still haven't got to the bottom of it.

I'm not sure what to investigate next. But I'm considering the following scenario: If a part is completely submerged, does its buoyancy then stay constant as its depth increases?

It also occurs to me that a precision altimeter mod would be highly useful. Then I could read off the height of the probe core above the water directly, rather than having to measure screenshots. VOID doesn't seem to do it, the altitude it reports is not that of the command pod (I suspect it is instead that of the CoM).

Link to comment
Share on other sites

Kerbal engineer has a read out of distance above water and above ground.

So when you are over water, it will measure the distance to the water and to the geound underneath the water.

If that was what you were looking for.

Edit.

I do not know if it calculates from the CoM or the object in control, though

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