Water Physics and Buoyancy

A Deep Look at ROBLOX’s Buoyancy and Water Physics

Water Physics and BuoyancyBoats. Waterfalls and geysers. Swimming and diving. Flowing rivers and deep pools. With version 1.0 of ROBLOX’s buoyancy and water physics, carefully crafted and researched by our Physics Team, these things are not only possible, but also realistic. We’re featuring ROBLOX Physics Engineers Kevin He and Tyler Mullen today, as they explain the latest iteration of buoyancy (see the original here) and its implementation in ROBLOX.

Water is more than a texture in ROBLOX. It has its own unique properties and behaviors, all of which integrate into ROBLOX’s existing physics engine. Objects float on water surfaces, bob up and down with pressure changes and sink if they’re too dense. Water flows, pushing objects along its path, with user-defined directions and velocity. Players dive underwater and swim the depths or wade on the surface.

The physics of water are rooted in buoyancy – the tendency of a body to float or to rise when submerged in a fluid, according to the Merriam-Webster dictionary.

[do action=”youtube-iframe” videoid=”aK79zNvNSts”/] Water physics in action: A working water wheel in ROBLOX.

1Buoyancy is a simple concept, but challenging to simulate in a virtual world. We approached the challenge with a few goals in mind. At a high level, we focused on clean architecture so the behavior of objects and characters in water looks and feels like a natural extension of ROBLOX’s existing physics. This included integrating buoyancy into our standard contact pipeline. We actually consider a body of water a special physics object and apply buoyancy to floating objects via the contact (or collision) between them and the water. This way, the collision between water and floater, floater and floater, and floater and sunken objects are all simulated in a unified engine.

Our architecture also unifies all the forces – buoyancy, water viscosity (drag) force, water-flow force, gravity, contact forces and other external forces. The movement of a floating object is a net result of all these forces on a rigid body following Newtonian laws. That’s why you’ll see an underwater collision happening in the same, natural way it does on land.

[do action=”youtube-iframe” videoid=”_SeB7pDUwqw”/] This video demos player control in and out of water, under water and on floating objects.

2We also strived to implement buoyancy and water physics with a high level of detail and accuracy. We came up with a couple solutions based on the type of object we’re simulating.

Cubes and wedges in water

Think about dropping a cube into water. After gravity has submerged it in water, it’s likely going to tumble and re-orient itself as the water’s buoyancy forces it back to the surface. In ROBLOX, we efficiently and elegantly simulate that re-orientation by dividing the voxel cube into eight segments, each of which has its own positional data. By dividing up the force of buoyancy, voxel objects (cubes, wedges and corner wedges) orient themselves properly and respond to changes in force – a character standing on one corner, for example – with realism. We also apply water viscosity force against both linear and rotational velocity to dampen the motion and achieve a good, float-y feel.

Cubes oriented based on density

Spheres and cylinders in water

Now, think about dropping a ball (or sphere) into water. Because the smallest point of the ball enters the water first, it gradually decelerates until the buoyancy force shoots it back up. We don’t need to worry about how the ball re-orients itself, but we do need to know how much of the sphere is below water.

If x is the percentage of the sphere’s height that is under water, then the percentage of the sphere’s volume that is submerged is:

Equation of percentage of sphere's volume submerged

And the buoyancy is weight of object × percentage of volume submerged ÷ SPECIFIC GRAVITY.

Cylinders are the trickiest of all. When cylinders are floating straight up and down, they should act like cubes. When cylinders are floating completely horizontally, they should act more like spheres. The trick, for cylinders, is to blend the two approaches.

If x is the percentage of the horizontal cylinder that is underwater, then the percentage of the cylinder’s volume that is submerged is:

Equation of percentage of cylinder's volume submerged

Again, the buoyancy is weight of object × percentage of volume submerged ÷ SPECIFIC GRAVITY.

This blend of the two approaches allows cylinders to behave realistically in water.

3Our final goal was to allow a wide variety of practical applications through water and buoyancy. You’ve already seen how objects behave in water, but we’ve also developed swimming and diving states that let players jump in and out of water, and swim downward to explore the depths.  Users will be able to construct realistic boats for their games and set up water-based platforming courses. With flowing water, your landscapes and architecture will benefit from waterfalls, geysers, whirlpools and streams.

There’s a lot of new ground – or, should I say, water – to explore.

[do action=”youtube-iframe” videoid=”yiwSIS-mmLg”/] Buoyancy in action: Boating in ROBLOX.

About Kevin He

Technical Director of Physics and Distributed Simulation at ROBLOX. @GongfuTiger on Twitter.

485 thoughts on “A Deep Look at ROBLOX’s Buoyancy and Water Physics

  1. Qij

    Can we at least make it transparent? OGRE has to support transparent decals or textures of some sort.

  2. sasoboy5 From Youtube

    Good Job.
    But U Could Re-new The Swimming Animation And The Water Texture, It’s Ugly :C

  3. joshuaallen2001

    You know what would be REALLY awesome, Roblox? It would be excellent if you ACTUALLY MADE WATER INSERTABLE IN ROBLOX STUDIO!!!!

    1. sasoboy5 From Youtube

      It’s Moderator Only Place From A Moderator. I Don’t Know From What 1 But I Know It Is.
      :P

  4. blablabla10

    Tl;dr, but I get the gist of what’s up here. Excellent work. I can’t wait to use this, it has so many possibilities!

  5. GPR3

    I don’t like the texture much, I’d rather boyancy be added to normal bricks like instead of a brick with moving decals on it : / but you’ve done a good job with the boyancy and I can’t wait for it to be finished.

    Same as cole xD

  6. cole7778

    I don’t like the texture much, I’d rather boyancy be added to normal bricks like instead of a brick with moving decals on it : / but you’ve done a good job with the boyancy and I can’t wait for it to be finished.

  7. Joseph

    I don’t like the texture much, I’d rather boyancy be added to normal bricks or set as a level on the entire map, but you’ve done a good job with the boyancy and I can’t wait for it to be finished.

  8. supersprayer

    please message me if this is out and how to use it or is it not out? PLEASEEEEEE just few clicks away

  9. Prehistoricman

    This looks great. As somebody said before, the physics of it still need a bit of working. And maybe you should allow game makers to change the texture of the water as a property of Terrain? I would also add properties and events of parts to do with water (Floating, HitWater, Sinking).

  10. CVW

    This is entirely scriptable……in their attempt to make it easier for scripters, they have “pissed” alot of people off. I wont even begin to list the number of things they have broken.

  11. Katuu

    I think you should make the diving more realistic, because one, who swims like that? (I know it would be hard to make realistic swimmng, but it would looks so much better) Two, when you’re underwater, the water is completely clear, although on the top it’s just blue. And make curves, the water is a little too blocky. And color change, and possibly transparency and texture change as well, so you could have clear water, or lava (implying you could add a script to the water or something). Ooh, and how about when dyamic lighting shines on it (or just any lighting), it could sparkle (moonlight) or glimmer (sunlight). Just something to think about.

    1. sasoboy5 From Youtube

      Yep.
      The Handling Is A Little Bit *Weird*.
      I Hope They’re Working On The Water Not-Clearness And Better Swim Animation.

      I Would Like If It Would Be With Moving Hands Forward.

  12. epicfin8

    Great job but dont you thibk it acts like too much like Minecraft like when you bounce on it and moves

  13. Nyan Cat Fan ===

    Awesome! Im not a fan of the texture though. Could you use a decal on roblox studio to change it to a more realistic water?

    1. DrDrRoblox

      Could you release the water ASAP? I’ve been waiting for nearly 5 months for this, ;/

  14. XXXFlashBackXXX

    It would b nice if this worked with the old bricks. Like if there were a tool that you could use to select a brick and make the brick water.

  15. moomanchicken

    i think the water should go over the the boat not just go right through it but other that thats its pretty good

    1. Seed100

      Cant wait for this, already got plans but one question, what about splashes? we can probably script them in but for less advanced players, they might need splashes although unimportant, thanks for ROBLOX.

  16. bunnyX123

    Most people are umimpressed just because of the dumb texture. But me, no, I’m impressed. You guys actually took the time to make objects float, and I believe this would make a good hit on Roblox.

  17. Babybob1234

    So much possibility. I can see some serious scripting and brilliant ideas going on with this water feature.

  18. sentinel

    Well, you know, this seems awesome, but does it use terrain? just asking because personaly it would be nice if terrain auto generated rivers and lakes.

  19. metaecho

    I cant wait for this feature to be implemented. Although you can tell it’s a work in progress. The rectangle in the “waterfall in ROBLOX” video slowed and continuously tried to right itself as it fell. If ROBLOX keeps heading in this direction, soon users will be able to build virtually anything they can think of. Great work :D

  20. SGTalpha43

    These new water features work pretty well, I’m sure these are well needed feature in ROBLOX it would work well in roplay, war games, obbies Etc.
    You guys seem pretty well set for it. One thing though work on the texture although it’s still a prototype…OH! I’m sure we could use the same formulas and idea for lava although when you touch the lava you burn and die

    1. A random person

      Are you thinking about mine craft? No but really, it would be nice if you just set a # of water bricks and then they spread out or flowed out of openings in the area

  21. rolandj

    It would be great,just with no waves pushing items just so the person looks like they are drowning like in the video.If you where doing a ship simulator it would throw the ship around like it threw the items in this video around.it would be great if someone jumps in and looks like they are swimming liek in the video.Just no waves throwing items around ;) ~rolandj

  22. 31allstar

    This is really cool although it could be worked on with the swimming a diving also the texture and waves

  23. IjustPOOPEDmyself1

    I think, instead of the water just flowing, and stopping at one point, and going in another direction, that it could possibly CURVE. So it looks less blocky, and more epic :3

  24. scacman1967

    This is great, it’s the second time you teased us with it and yet I haven’t seen the implementations of water. We love it, we want it , we can’t wait so please hurry.
    Thank you very much for roblox.

  25. eva2313

    This will go GREAT in city games :D But as mentioned,maybe you could have a feature that you can enable or disable;the ability to drown? It can even go towards the Robloxian Pool game,so if you drown,you go to the lifeguards or something :D

  26. Bryle45

    When the object removes, let it edit out the objects smooth or that function I use for common ice and make it feel wet and or slippery for a while, soon maybe soon.

  27. mariopartystar

    1 word ROBLOX Admins… “Brilliant” *Applause*

    *Great Work with the New Physics*

    Gameplay is filled with excitement.

    All we need now is a lag-reducer programmer.via or just something else that’s great.

    MarioReviews: 9.2/10.0

    1. outahere

      Absolutely brilliant.

      Great job devs.

      Isn’t this a lot better than random hats, and gear that often breaks?

  28. zarin1999

    THIS IS EPIC I CANT WAIT!!!! guys who make roblox try to make like animation more then c-frame like actuall vidios/movment tools

  29. LowSonic1234

    Wow, these new physics are just awesome!

    They will work insanely great on my games I am working on, especially my sword fighting game!

  30. SecretAgentWolf

    I’ve already made a set of boats in preparation for this. Say, about the sails on the sailboats, are those sails real “cloth”? That’d be so cool to make sail-rafts and sail-boats and other such! :D

  31. kozumi

    if its as complicated as it sounds, then water will be amazing. as long as it doesnt lag. im very enthusiastic about water coming out, as it is a very basic ingredient in building landscapes.

  32. TheBlockMan55

    There is still a few glitches but good job anyway. Looks like it took you a long time especially because you showed the formulas on how to make cylinders or cubes have buoyancy. Still none of those formulas look new to me.

  33. jamezo1

    Its good but u cant stay down for too long and still be alive you should do this when u dive u satya under too long u loose health like in real life

  34. pingy8881

    I love the new Buoyancy and Water Physics that you guys are working on, it would make boating games/water a lot more realisitc and.. it would just make ROBLOX better and better!

    Awesome!

  35. mat852

    Why couldn’t you guys add this to normal bricks? 80% of games now don’t use terrain. How will the professional game developers use this feature if they don’t use terrain?

    1. derp

      Exactly what I think. The normal bricks, which most of us still use, need this update. Otherwise, people will just resort to what they have done for a year or two, which is script it in.

    2. 69scott69

      Even if you don’t like terrain, I can’t see why you couldn’t add the ‘water’ in Brick building. You can add little bits of terrain in Brick building if you want.

Comments are closed.