Make it drop like real liquid

Hi guys,

Picture this:  A cave stalactite with dripping liquid from its tip.   

I have been experimenting a lot on Liquid Fun to get the effect I wanted.  How do you make particles (liquid fun) drop like real liquid?  They drop like feathers!  

I have played around a lot on its parameters, even cranking the gravityScale and density way too high, and still the particle seem to float its way to the ground.  it doesn’t seem to be responding to gravity settings.

The only way i can get it to drop close to realistic is when i use same values for radius and  imageRadius (eg, 2 and 2 respectively), but doing so the droplet doesn’t splatter (disintegrate into more droplets) as it hits the ground.   

Any tips?  

Santi

I would think normal world gravity of 9.8 on Y, 0 on X. Density of 1.0  and no additional gravity on the object should represent water the best.

Rob

Hi Santi,

There are too many factors in LiquidFun to determine the issue “blind”, so we’ll need to see your code that shows how you’re setting up the particle system and other aspects of the simulation.

Thanks,

Brent

Hi Brent,

It’s pretty much the same as the many examples given.  In fact, I copied it from one of Corona examples.  It’s working in the game the way I intended it to do EXCEPT that I still wanted to tweak it’s drop characteristic to mimic how liquids in real life (and other box2D physics bodies) drop.  Imagine a newCircle obj with a gravity scale of 4 or 5 in a normal 9.8 gravity - that’s the kind of drop I wanted.

I think liquid fun is designed to work as large blobs or  “mass” of particles to simulate liquid, rather than as single isolated particle.    

    

To illustrate what I mean, please consider the two codes below: 

This code is using particle system, working on single particles at a time:  (NOTE: You can copy the particle.png in the Corona liquid fun examples) 

-- main.lua local physics = require( "physics" ) physics.start() display.setStatusBar( display.HiddenStatusBar ) local center\_piece = display.newRect( display.contentCenterX, display.contentHeight-135, 200, 10 ) physics.addBody( center\_piece, "static" ) center\_piece.rotation = 15 -- Create particles -- local particleSystem = physics.newParticleSystem { filename = "particle.png", radius = 2, imageRadius = 2, --gravityScale = 4, --density = 1.5, } particleSystem.name = "acid" -- define particle params local particleParams = { flags = {"water", "fixtureContactListener" }, -- fixtureContactListener for later collision color = { 1, .50, 0, 1 }, x = display.contentCenterX, y = display.contentCenterY - 100, --velocityX = 300, --velocityY = 500, lifetime = 10, radius = 2, } -- Generate particles "droplets" local function onTimer( event ) particleSystem:createParticle( particleParams ) end timer.performWithDelay( 1000, onTimer, -1 ) -- end main.lua 

Notice how the “droplets” seem to be just transitioned to with a slow time.   They don’t seem to be pulled by gravity in a more natural way.   Changing gravityScale and density doesn’t appear to have any effect at all.    

Now look at this code using newCircle.   Watch how the circles drop:

--- using newCircle as droplets ---- local physics = require( "physics" ) physics.start() display.setStatusBar( display.HiddenStatusBar ) local center\_piece = display.newRect( display.contentCenterX, display.contentHeight-135, 200, 10 ) physics.addBody( center\_piece, "static", {bounce=0, friction=0} ) center\_piece.rotation = 15 -- Generate the "drops" local function onTimer( event ) local droplet = display.newCircle( display.contentCenterX, display.contentCenterY-100, 2 ) droplet:setFillColor(1, 1, 0, 1) physics.addBody(droplet, "dynamic", {density=1.5, friction=0, bounce=0} ) droplet.gravityScale = 4 end timer.performWithDelay( 1000, onTimer, 10 ) -- end main.lua 

Notice how the “droplets” drop like real gravity pulled them   :slight_smile:   This is the particle drop behavior I wanted.   

If somebody can help me get the latter drop effect for the particle system, I’ll be very happy   :slight_smile:   

The reason I prefer to use particle system over the newCircle “droplets” is I want those droplets to accumulate in a container, and thereafter behave like liquid .  

Cheers,

Santi

Have you tried playing with physics.setTimeStep()?  What you are describing sounds like an issue I had a while back when changing an app from 30fps to 60fps.  Sorry for the short reply, I am on mobile right now.

Why not have your drop just be a regular Box2d object until it collides with the body of water it’s falling into and then add it to the liquid fun set of objects.  You could probably use a pre-collision check so that it starts interacting immediately to get splash effects.

Hi @santiagoluib3,

If your goal is to make a drop fall and “splatter” like liquid, you should almost definitely use a LiquidFun particle group , shaped like a drop (or a circle or whatever) – not a single particle. That way, it will fall and naturally splatter into separate particle drops which will incorporate themselves with other liquid particles.

https://docs.coronalabs.com/api/type/ParticleSystem/createGroup.html

Hope this helps,

Brent

Hi Brent,

Thaks for the feedback but yes, I have done that and I am aware that single particles DON’T splatter into droplets when they hit other physics object.  But having it in Groups only seem to make the drop even slower and more linear, like a transition tween.    

I purposely made it a single particle in my code example above to compare the drop characteristic between particle system and standard box2d object (eg. newCircle) subjected to similar physics (gravity force, garvity scale, density).  

Cheers,

Santi

Hi Santi,

Have you tested out our sample project on LiquidFun groups? These are falling at a reasonably natural and expected speed in my opinion, so maybe it can be used as a guideline for your project:

https://github.com/coronalabs/samples-coronasdk/tree/master/Physics/LiquidFun-ColorGroup

Brent

I would think normal world gravity of 9.8 on Y, 0 on X. Density of 1.0  and no additional gravity on the object should represent water the best.

Rob

Hi Santi,

There are too many factors in LiquidFun to determine the issue “blind”, so we’ll need to see your code that shows how you’re setting up the particle system and other aspects of the simulation.

Thanks,

Brent

Hi Brent,

It’s pretty much the same as the many examples given.  In fact, I copied it from one of Corona examples.  It’s working in the game the way I intended it to do EXCEPT that I still wanted to tweak it’s drop characteristic to mimic how liquids in real life (and other box2D physics bodies) drop.  Imagine a newCircle obj with a gravity scale of 4 or 5 in a normal 9.8 gravity - that’s the kind of drop I wanted.

I think liquid fun is designed to work as large blobs or  “mass” of particles to simulate liquid, rather than as single isolated particle.    

    

To illustrate what I mean, please consider the two codes below: 

This code is using particle system, working on single particles at a time:  (NOTE: You can copy the particle.png in the Corona liquid fun examples) 

-- main.lua local physics = require( "physics" ) physics.start() display.setStatusBar( display.HiddenStatusBar ) local center\_piece = display.newRect( display.contentCenterX, display.contentHeight-135, 200, 10 ) physics.addBody( center\_piece, "static" ) center\_piece.rotation = 15 -- Create particles -- local particleSystem = physics.newParticleSystem { filename = "particle.png", radius = 2, imageRadius = 2, --gravityScale = 4, --density = 1.5, } particleSystem.name = "acid" -- define particle params local particleParams = { flags = {"water", "fixtureContactListener" }, -- fixtureContactListener for later collision color = { 1, .50, 0, 1 }, x = display.contentCenterX, y = display.contentCenterY - 100, --velocityX = 300, --velocityY = 500, lifetime = 10, radius = 2, } -- Generate particles "droplets" local function onTimer( event ) particleSystem:createParticle( particleParams ) end timer.performWithDelay( 1000, onTimer, -1 ) -- end main.lua 

Notice how the “droplets” seem to be just transitioned to with a slow time.   They don’t seem to be pulled by gravity in a more natural way.   Changing gravityScale and density doesn’t appear to have any effect at all.    

Now look at this code using newCircle.   Watch how the circles drop:

--- using newCircle as droplets ---- local physics = require( "physics" ) physics.start() display.setStatusBar( display.HiddenStatusBar ) local center\_piece = display.newRect( display.contentCenterX, display.contentHeight-135, 200, 10 ) physics.addBody( center\_piece, "static", {bounce=0, friction=0} ) center\_piece.rotation = 15 -- Generate the "drops" local function onTimer( event ) local droplet = display.newCircle( display.contentCenterX, display.contentCenterY-100, 2 ) droplet:setFillColor(1, 1, 0, 1) physics.addBody(droplet, "dynamic", {density=1.5, friction=0, bounce=0} ) droplet.gravityScale = 4 end timer.performWithDelay( 1000, onTimer, 10 ) -- end main.lua 

Notice how the “droplets” drop like real gravity pulled them   :slight_smile:   This is the particle drop behavior I wanted.   

If somebody can help me get the latter drop effect for the particle system, I’ll be very happy   :slight_smile:   

The reason I prefer to use particle system over the newCircle “droplets” is I want those droplets to accumulate in a container, and thereafter behave like liquid .  

Cheers,

Santi

Have you tried playing with physics.setTimeStep()?  What you are describing sounds like an issue I had a while back when changing an app from 30fps to 60fps.  Sorry for the short reply, I am on mobile right now.

Why not have your drop just be a regular Box2d object until it collides with the body of water it’s falling into and then add it to the liquid fun set of objects.  You could probably use a pre-collision check so that it starts interacting immediately to get splash effects.

Hi @santiagoluib3,

If your goal is to make a drop fall and “splatter” like liquid, you should almost definitely use a LiquidFun particle group , shaped like a drop (or a circle or whatever) – not a single particle. That way, it will fall and naturally splatter into separate particle drops which will incorporate themselves with other liquid particles.

https://docs.coronalabs.com/api/type/ParticleSystem/createGroup.html

Hope this helps,

Brent

Hi Brent,

Thaks for the feedback but yes, I have done that and I am aware that single particles DON’T splatter into droplets when they hit other physics object.  But having it in Groups only seem to make the drop even slower and more linear, like a transition tween.    

I purposely made it a single particle in my code example above to compare the drop characteristic between particle system and standard box2d object (eg. newCircle) subjected to similar physics (gravity force, garvity scale, density).  

Cheers,

Santi

Hi Santi,

Have you tested out our sample project on LiquidFun groups? These are falling at a reasonably natural and expected speed in my opinion, so maybe it can be used as a guideline for your project:

https://github.com/coronalabs/samples-coronasdk/tree/master/Physics/LiquidFun-ColorGroup

Brent