How to emulate roblox's buoyancy system in part water?

Hi,

I make games that often include things like ships, I have made them work before both with/without roblox terrain water, but to be honest roblox’s water has the best buoyancy compared to my janky versions.

Roblox water is remarkably laggy and increases load times to an unbearable amount.

Is there a method similar to HighPerformanceWater where I can copy this buoyancy behavior to work with parts rather than terrain water?

Yes, I have tried making my own system, it doesn’t work well. I’m looking for alternatives, or a straight-up solution, not coaching on how to fix my janky buoyancy system.

Thanks.

I have not tested this solution at all but based on my AP Physics 1 knowledge here is my two cents:

  • The buoyancy of an object is based on two things: force of gravity (Fg) & bouyant force (Fb). Fg = mg (mass * gravity), and Fb = pVg (fluid density * submerged volume * gravity)
  • Objects will float while Fb > Fg, and the object will be at rest when Fb = Fg, where only a portion of the object’s volume is submerged.
  • If I were to try to implement this knowledge into Roblox Studio, I would apply a force object on the player’s HumanoidRootPart, where the force is just the buoyant force. At every Stepped event, I would first check if the player is inside a water zone/volume. If so, I would check the distance between the player’s Y position and the water’s center Y position.
  • Assuming the height of the character is 5 studs, we know that the player must be fully submerged in the water if distance < water.Size.Y * 0.5 - 5 (or the distance is less than half the Y size of the water subtracted by the character’s height). In that case, we can just set the character’s buoyant force to a predefined force value that we know will cause the player to rise up (which I will refer to as max buoyant force).
  • However, if the player is outside this safe distance, we will need to calculate the percentage of the player’s height that is inside the water, and then multiply this percentage by the max buoyant force.
  • One potential flaw I see is that with random parts or ships, having just 1 point of force may cause objects to spin when we want them to be rotationally stable, so applying multiple smaller buoyant forces (that add up to the desired buoyant force) at different points of an object may help with this.
  • Also make sure that when you apply the force(s), they should ALWAYS point vertically upward regardless of the rotation of the object/character.
2 Likes

Thank you for this.

I will give you the solution since this is most likely the best answer to my question, however, I just ended up using a part ocean and plane constraints to keep the boat level.

Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.