Water droplet physics simulation

Probably yes. But if you need droplets to squish on ground, then this script won’t do this for now.

1 Like

How can I destroy the droplets?

2 Likes

Tbh I forgot about thing that you may need to destroy them, I’ll update code now :sweat_smile:
EDIT: now you can simply call :Destroy() function on Droplet part.

1 Like


For anyone who wants a video:

To OP: It looks decent, I won’t say amazing but just decent as its quite slow, and not realistic.

14 Likes

Hm… strange thing is that it slided on my pc normally trough all this surfaces. I’ll try to fix that now.
Edit 1: this’s caused by “sleep mode”, which tries to use less calculations if droplet speed is < 0.1. Trying to change some logic.

1 Like

Finally, a long journey came to an end… Well, actually, not quite, a lot of improvements can be made till it reaches the point of actual droplets, but for now, very well done :clap:.

3 Likes

I think I fixed droplet sleep problem.
About why they slow: I use constant gravity 9.8, and you can change that value in script. So, multiplication by 3 (29.4) will result in x3 simulation speed.

1 Like

Hi,
How about adding to it when the water ball is about to dissappear , it becomes flat like a water drop… then dissappears …
Thankd

1 Like

This looks amazing, Holy crap, I am impressed with this resource, honestly I might use this for something in the future.

2 Likes

Wow, amazing! Everything works great. It has some issues with unions though.

Can you tell me them, so I’ll be able to fix them?

So I tried to have a block with a sphere negated in it, to make a bowl, and the water sometimes clipped through the bowl section. And other times, it just jiggled quickly.

Can I ask you, is dropled clipped trough bowl, and then fell trough it? or it was visual clipping only, and not physical?

I saw it fall through, so physical.

1 Like

I think it would be more optimized if you would make your own system for collisions between Droplets. Here are two options for implementing it:

  1. For every particle, you could iterate over all particles and check distance between them. But this option is very bad for performance.
  2. Slightly harder option would be to implement Spatial Partitioning technique. Instead of iterating over all particles for every particle, you could store particles in a 3D Grid, and for every particle you could check for collisions between particles in nearby Grid Cells. You will see a big performance difference than in first option. I use this technique in my Module so i advice you to do the same.

hey, you should try doing this but using meshdeformation
like imagine a ball, throw bones into that, port it into roblox, make code, when a ball collides with eachother the bones position themselves to the other droplet and increase size, (if its a droplet), if its a big body of water like a small waterfall for example, itll slide down the river, and stay as a entity, but be connected to the water.

Wouldn’t that be bad for performance?

Hello.
(First one important message before reply)
Guys, I had read everything above, and should tell you that I will be unable to update it until new year due to the amount of work I need to do for highschool. Sorry.

(Reply below)
Won’t it be more time consuming to move droplets from 1 grid ceil to another one, check where droplet relatively to grid? I think that magnitude scheck is best here, BUT If you can tell me why and how grid can be better, I’ll probably can try to make it. (After bug fixes + new year)

I just figured out that workspace:GetPartsInPart() probably also uses spatial partitioning (not sure tho). But even if there is spatial partitioning on it, i think it would be better to make your own Spatial Partitioning. And that’s because GetPartsInPart() uses collisions to check if a Part is in part, and because droplets are circle shaped there is no need to calculate collisions with mesh, you can just check for distance between two particles to see for collisions.
Also, maybe i confused you a little, the spatial partitioning method still uses distance checks but only does them on adjacent grid cells so instead for checking every droplet for collision, you just check collisions on few particles that are in adjacent grid cells. Also when using Spatial Partitioning, it is easier to implement Multithreading which can boost performance alot. Many Physics engines use Spatial Partitioning, so it would be a good idea for it to be implemented also in your work.

Ive made a fairly fast real-time fluid particle simulation: