Custom Medium Physics (Open Source)

UPDATE: The project is open source now!

About the project

Lately, I have been working on a custom physics engine for simulating how parts behave in mediums such as air and water. It was quite hard to get it right, since I had to deal with problems like numerical instability, time synchronization and unit conversion (porting kilograms and meters to Roblox and vica versa). Eventually, I managed to solve these with some help from the forum and friends. I managed to put my calculations to the test by spawning a part with a density of 0.997 in the water (my water has a density of 997 kg*m^-3). It was supposed to float in the water, since it had the exact same density and it did.

After accomplishing some succesful simulations, I thought about what I wanted to do with them. So I decided to add infinite water using skinned meshes. My plan is to open source my sea on GitHub at some point in time, since a lot of people are trying to make a sea using skinned meshes. There are some tutorials on making a sea using these meshes, but they do not show you how to exceed 2048 studs (which is the maximum size of a MeshPart).

For now, I decided to release a showcase to share it with people. So here it is: Medium Physics Showcase (Open Source) - Roblox. The spawnable boats do not have GUI support, so these are the controls:

  • Hold Q/E - Sails
  • Hold W/E - Propellers
  • Hold A/D - Rudder

The arrows indicate the forces that act upon a part, where:

  • Blue = Medium Force
  • Yellow = Buoyancy

Place file:
CustomMediumPhysics.rbxl (111.5 KB)



This is impressive, well done. I especially like the physically simulated waves, even if they’re just sine waves for now.

When you do open source this it will be a huge help for me and a whole lot of people. I currently still rely on terrain water for large oceans and it looks nice and has good physics but the resource usage is ridiculous.


Yeah, it is definitely not made for low-end computers. I can probably implement Gerstner waves at some point.

Tip: try the sail boat instead of the motor boat if you want to see the physics in action. The wind direction is paralel to the waves direction (yes you actually have to ‘sail’ your way forward).

I would love to have this open-sourced, been searching for a solution for client and server sync & float physics and couldnt find it anywhere. This looks amazing!

1 Like

It is actually more than buoyancy. Have you tried the sail boat? You can actually sail like you can irl.

1 Like

I have, its really cool. I really love it honestly, cant wait to (if open-sourced) use it!


Quick question! Do the boats have weight values to make it not too floaty on the water to point of no control?

I estimated the submerged ratio, which I use for determining the density of the medium. This way, you can smoothly transpose between water and air.

1 Like

I open sourced the project, so you can take a look if you want.


I want to start off by saying that this resource is a godsend and has been a massive help to my projects.

I have run into an issue and it’s proving to be a bit of a pain in the back.
I have noticed that the further away from the center of the world you are, the less consistent and refined the waves are. Basically, they look more “jagged” the further you go out.

(At spawn)


(Far away from spawn)

It’s worth noting that I have performed some modifications to the source code, ie; changing values to make a less dramatic water. I have also removed all of the physics related kit that comes installed so that it is very much just the skinned mesh water. However, the problem is consistent with the original.

Would you be able to help me solve this problem?

1 Like

I’m not sure if you have another post about this in #resources:community-resources, but since it’s open source, wouldn’t this belong there?

Yeah, probably. I did not open source it initially, which is the reason why it is here.

1 Like

I am aware of that. Chunks that have a different level of detail do not overlap perfectly, which causes them to look jagged at times.

I later found out that you can scale MeshParts past 2048 studs. This means that as a solution, you can make a circlular skinned mesh with a high level of detail in the center and a lower one towards the border. Then you can update the bones like the current system does. This way, you get rid of the chunks and therefore the jagged-looking effect.

So basically the solution is:

  1. Make a circular skinned mesh with a high resolution in the middle that lowers towards the border (for performance)
  2. Load it into Roblox Studio
  3. You can use the same script (and modify it), since it is made to work with any skinned mesh
  4. Adjust the script to displace the bones further away from the center (in order to scale the mesh past the 2048 studs limit)

EDIT: I found out that textures deform depending on the triangle size that they are rendered on. So having a mesh that consists of triangles of different sizes will result in visibly altered textures. Therefore, I recommend to copy the methods that are used to make this sea instead if you want to go for great aesthetics.

1 Like

Can you send me the place file? I’m trying to edit the place but I can’t. I’m having a hard time figuring out the size of the wave from where the player is

The place file would very much so be appreciated, as @marcosOP007 mentioned.

Can’t seem to edit from the game page.

1 Like

I included it in the topic before ‘References’.


It is open sources!

Place file:
CustomMediumPhysics.rbxl (111.5 KB)

Hello again!

I’ve been experimenting around with the look of the ocean to try and make it feel more “oceany”. I recently discovered that it’s possible to add texture scrolling to skinned meshes and I have been hellbent on trying to figure it out. I have so far only managed to get it working in one plane.

After much poking around I can’t find anywhere to implement this and given my general lack of knowledge on code in general, I don’t know how to add a separate script to handle it for me.

-- ("texture" is just a placeholder variable for a texture in the plane)

for X = 1, 3000 do
		texture.StudsPerTileU += 1
		texture.StudsPerTileV += 1

I want to run this simple UVoffset scrolling loop in every chunk model. How and where do you think I could best implement this?

Desired effect (replicated on alternate water):


I’m really sorry for bumping this, but I just can’t find a way to add physics to my own objects. They are just objects, not actual boats, like trash and stuff