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

    I saw the article before and I loved it, and I still love it! I hope this will be in roblox soon.
    My suggestion for next project: WEATHER in Roblox, TEMPERATURE, NEW WALKING MOVEMENT, and NBC PACKAGES.

  2. edward123456

    Epic i can imagin my self dressed like a fish/whale/seal/ dolfin and swiming and doing tricks in water. xD

  3. rocklee2016

    I don’t want the water to be terrain, or else it will be useless for many of the expert builders across ROBLOX. I personally prefer just the fake water brick over this currently.

  4. liama517

    A couple of days ago I was needing water. This is so cool, there are so many improvements since the last post.

  5. BASEWAR713

    Cool! I can imagine my ROBLOXian diving in water, coming out and diving back in. All we need now are physics that look like water is still on our ROBLOXian

      1. ShadowNinjaWarrier

        and water shaping like terrain but could use a little more for water then terrain has

    1. ROBLOXluver456

      Very interesting. You ROBLOX Admins have heard of M.I.N.E.C.R.A.F.T? In it, when you go under water, a gauge will appear over your health meter. It tells you how much oxygen you have until you die.I also think marine life should be involved and they die on land. Submarines seem cool as well. ROBLOX is simply the best game ever. It contains all categories, and you can design your own games that you seem to favor. M.I.N.E.C.R.A.F.T is okaaaay, but seriously, ROBLOX allows you to create any game with ease PLUS! You are moderated so no people can come in games with profanity like M.I.N.E.C.R.A.F.T. I have got at least 5 friends to join ROBLOX. I’m glad you’re working hard to make my favorite game better. Thank you ROBLOX. :)

      P.S. Is Ipad ROBLOX going to be free or not? Also, can you distribute the estimated year of release? Sorry for the bother but, also will the game itself be updated onto the app or a separate app? On more thing, I think the Catalog and New games should be added to app. :3 bye! You all rule. xpthreethousand@yahoo.com is my e-mail :3. I Might send you guys loads of suggestions!

    2. Pieguardian

      Nicely done ROBLOX. The only things I have to say are

      1.) You may want to make sure users cannot swim up waterfalls. I noticed a beige brick kind of flipping slowly down the waterfall, it was slower than the other bricks, and it made me think that users may be able to do this, except move themselves UP.

      2.) I was kind of hoping water would spread throughout an open area. For instance, you make a waterfall, and the waterfall is the source of the water. So perhaps you could make the water fill up an open space, and rise if it starts getting full.

      Thanks for the great updates.

  6. supercoolguy26

    This seems SO cool! I think that you should make it an option to have it flow or not, and make it so that the water doesn’t just go into the sailboat, like it showed in the video.

  7. Cristisinme

    This is great however there could be alot of issues like how to control/stop the flow, alot of people want o2 bars, and could the density of the water be changed to alter the drag of the water, if the water floods… all of these would be hard to script in unless you add all these otions into properties. Btw i love all the work you guys are doing right now. Can’t wait till the final product comes out BD

    1. Cristisinme

      Quick note: make it so you CANT destroy it with explosives unless you give us a way to regeneratte it like you did with the terrain

  8. RobyTobyRobot66

    Good. But it’s missing one key feature. When you dive down, there’s just the water brick above you and the terrain. The water, when you place it, should go downwards and fill up the hole you place it in. And it should be realistic, not filling up the big hole with a small amount. Make it so where you have to put a lot until it fills up. And make your screen also a little bit of blue tint, if you can. Also if you can, make the top of the water underwater a little bit light blue to look like it’s shining.

    1. TheBlockMan55

      Of course that would cause too much lag because of all the matter that is moving around. Especially in a tsunami one exception is if you just make the tsunami out of the voxel cells and try to make an animation, break and remove, and kill script to it. The hurricane would pretty much be impossible on ROBLOX’s format.

  9. whit(GODDZILLA24)

    ok awsome!!! but ive said tis many times befour, BUILDERS SHOULD HAVE THE POWER TO CHOOSE PHYSICS FOR THEIR PLACES!!!!!!!!!



    I have been waiting a long time for this and now it’s finally here! I’m very excited about this new physics advancement, plus I feel proud I somewhat understood those complex equations. xD

    In the future, if you could, I would really appreciate it if you’d think about adding some of these other features (if you haven’t already) to the water physics:

    1.) Make it so we can change the velocity, streamflow direction, and bouyancy as well as the color of the water (so we could make it green for slime or something xD)

    2.) Make lava just like the water except it’s ‘firey’ and deals damage to your character

    3.) Make it so the water could put out fires (this could be used in a lot of scenarios)

    I’m not saying you HAVE to do these things, just use them as ideas for the future. Thanks so much for the Water Physics update Roblox! Keep up the great work!

  11. R3gebiscuit

    Looks pretty good so far,Im hoping it has a ‘Wave’ setting where the water brick will actually increase and decrease on it’s own without the aid of building tools.
    But also the ability to change it’s colour,reflectantcy and transparentcy.

    1. rocklee2016

      I know. I, like many users, hate the terrain. A blue transparent brick looks more realistic than the current terrain water.

  12. Anonymous

    Way too cool! This is one of the things I was waiting for on Roblox! Good Job Roblox! Two Thumbs Up! :D

  13. Bellade

    OK I have a Idea Cant you Like Make weight on It like You go to the End of the boat with alot of the robloxains it will start to tip on its back Could you do that-Idea From Bellade On Roblox.

    1. Cristisinme

      You know that is included in each individual brick in other words every brick that has a joint to another acts as one brick

    1. Michael

      ROBLOX Studio, I bet. It would be easier in Studio because the stamper tool is good for inserting stationary bricks, not flowing water. If water was ever associated with the Stamper tool, it would be pools, sinks, etc. I think water will be a new object when you go to the Insert window in Studio. I hope that it has more characteristics of real liquid and is able to spread out, like Minecraft.

  14. thinkableant

    You should really put breatheing bar when you dive and your breatheing goes down and it goes completly down your health goes down a little bit

  15. clawdude97

    few things that would be kinda cool:

    1:make it so water could put the fire out

    2:it could be placed with a stamper tool

    3:make lava to go along with this!


  16. funnymouse7

    I wet my pants from happiness from watching this but when you go under the water your screen should become blue and the swimming bit is awesome!

  17. Fatpop

    Urm. Amazing. Just I think it should be coloured if you go underwater. Like real life. Like a dark blue.

  18. Anonymus

    (The reason I am saying my name is Anonymus is because I am using a computer at school in a different classroom than my own)
    I cant wait to use this in my new Hunger Games game!

    1. towleboy

      Dude you kind of gave your self away by saying you made the hunger games and i can’t wait for you to add it in your game is one of my favorite games

    1. jacobarnold

      The same way you insert other terrain because the only real diference between this terrain material and other ones is the CellMaterial Property and the fact that its CanCollide false and affects part objects that are in it.

  19. KingOfTheInterWebs

    I’ve been looking forward to this. But a little question. As Sethalonian said why does it have to be terrain? I mean terrain is an intresting feature and all but as Sethalonian said what’s the point of bricks and all things ROBLOX if your not going to use them?

    1. Kevin He

      That water cells, in the current iteration, contain key properties of the water such as flow direction and speed.

  20. Alex

    Great, not only can i annoy people by using the new blocks and making them go on for every, but i can also drown them and bring them all the way back to the start of the map, nice touch.

  21. Cooldude816

    Looks really nice. Sadly, this will still need A LOT of work. On the waterfall, one of the water falls, the water is going up. Also, when your under water, you can’t see the water, only the terrain. The layout and texture needs to be worked on a lot as well. I think ROBLOX’s textures should be more transparent, and the water clear. The MC water is ideal, but I know you want to keep as far away from it as possible. You also will need a lot of flexibility with this new aspect, like create a place where water mass comes out of. I also think flooding needs to be added. Like you can make the water come off your baseplate so it doesn’t flood, but if you don’t, the whole game floods? Or maybe add a tool in edit/build mode so you can select heights and boundaries for this. Overall, keep up the good work! This could bring new prosperities to ROBLOX game play. I can’t wait :)

    1. tikatok

      I think you should be able to drown in it but otherwise it is pretty cool. Maybe like an old game where it counts down once you stay underwater long enogh.

      1. ROBLOXDUDE741

        Yeah the drowning idea is a good suggestion, just like the script Wingman8 used in his Galleons game.

    2. Kevin He

      Water flowing up ? Nice spot. Probably just a texture glitch. I’m sure it’ll get fixed in production.

  22. Sethalonian

    My Problems with it.

    1. Why must it flow? Why not just let it sorta let its speed be 0 then let the character swim where he wants….

    2. Why must it be Terrain. What are the point of bricks if we won’t even use them…. And it would be much cooler if you could CFrame it…

    1. Kevin He

      1. You can set up the water as static with speed 0 as you wish.

      2. They are just voxels, 100x cheaper/faster than standard parts. They exist to hold key properties for water cells so that you can setup complex water torrent via scripting.

  23. Macaroniwolf

    This is epic! Can’t wait until this is out, it will change the way any game with water in works. I was planning to build a group base with a river in, just using a slightly transparent non-can-collide blue sheet to represent the water, which people would fall through when they fell in (I wanted it to be lethal). But now, on second thoughts, I will wait until this is implemented and it will be awesome.

  24. Gutiotyu

    Awesome, but I don’t really like the mesh. Should be more realistic or able to transparent it(Maybe also able to delete the mesh too) :L

  25. starfox3213

    Thanks ROBLOX, with the water transparent upgrade. Sooo… Excuse me while I go make it. -Starfox3213

  26. linkrocker

    This looks amazing! Not only will it open new updates to my games, but it lets players be even more creative! I can sense many more obbies coming soon.

  27. Lucassen

    That is purely awesome! I’m expecting that we can change alot of the properties on the water… Transparency, color, flowdirection?

    Also, for advanced game makers, they should be able to edit a block’s buoyancy. As an example, making steel float and wood sink.

  28. Nullmario45

    I can’t wait!
    I have a few questions, Can you change the water flow speed? Also will you be able to place the water in personal servers?

  29. Cheeseboy999

    Does pressure in the water increase if you go deep? For instance, would a robloxian implode if he or she swam too deep below the baseplate?

  30. eletrowiz

    Very nice, some questions though,
    Will it be script-editable, or be able to fire script functions? Also can the texture be edited by the user. Finally would it be possible to have the screen slightly blue when underwater?

  31. Paleontolgy

    Its seems a great idea, but my only question is will it work with conventional models? So if you drive a car into the water will it still have physics inflicted upon it…

    1. Kevin He

      Of course, your car will flip and roll and sink down to the bottom of the lake unless … you build a car out of wood or plastic.

Comments are closed.