Jump to content

Unambiguously decide if a part is under water


Recommended Posts

I'm looking for a way to decide if a specific part is under water.

I would like to know if it is in contact with the water and if it is entirely submerged and its depth.

I'm looking at Part and PartBuoyancy, but I'm not sure exactly what all of the values are.

Are Part.depth and PartBuoyancy.depth the same? Do they represent depth underwater?

Will PartBuoyancy.submergedPortion tell me the percentage of the part (or its collider, or maybe drag cube) that is underwater as the name suggests?

I assume Part.WaterContact is true if any amount of the part (or whatever stands in for the part) is underwater.

I could probably check all of this in-game :P, but I won't have a chance to get to it for a few days.
Link to comment
Share on other sites

Part.submerged (or is it submergedPortion?) defines what ratio of the part's total displacement is under water. PartBuoyancy sets it each tick, but use the Part version since that means your mod will work with any mod that replaces PartBuoyancy.

If you do want depth (depth at centerOfDisplacement), minDepth (depth at part's highest point, more or less), or maxDepth (depth at part's lowest point, more or less) then you do have to go into PartBuoyancy.
Link to comment
Share on other sites

Thanks, that more or less confirms what I thought.

I went ahead and checked this in-game, just in-case anyone else is looking for the same info.

The Part. depth, minDepth, maxDepth, and submergedPortion all give equivalent values to their Part.PartBuoyancy equivalent.

submergedPortion gives a 0-1 percentage.

The depth values give a number in meters below the surface, and return negative values when above the surface.

And WaterContact returns true only when the part itself is actually partially, or completely, submerged.
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...