Hi, I have been having some trouble with the LiquidFun physics engine regarding the motion of the particles in relation to Box2D rigid bodies. First, the particles fall at a much slower speed than other physics bodies. Increasing the particle radius to a certain extent fixes this, but then the particles look more like a bunch of large balls than a fluid. gravityScale seems to only be able to slow them down even more and not speed them up. Another problem is with the velocity of the particles. The applyLinearImpulse() and applyForce() methods as well as the initial linearVelocityX parameter can only move the particles up to a certain speed (which is very slow). Again, increasing the particle size fixes this but it does not look very good. This could just be a limitation of the physics engine, or there could be a simple fix I am missing. Any input would be much appreciated, thanks!
There are many factors which could be contributing to this. I think we’ll need to see some code around how you’re setting up the particle system and particles and other things you’re doing to them.
Remember to surround your code with “lua” tags for clarity:
[lua] ... [/lua]
Thanks,
Brent
Hi Brent, thanks for responding. It seems like a fairly normal implementation:
local water = physics.newParticleSystem( { filename = "drop.png", radius = 3, imageRadius = 4, gravityScale = 5,--doesn't do anything density = 1, } ) local watparam = { flags = { "water", "colorMixing" }, linearVelocityX = 10000000,--barely moves color = { 0, 0.3, 1, 1 }, x = 4200, y = 1000, lifetime = 50.0, radius = 30, } water:createGroup( watparam ) water:applyForce(10000000,0)--doesn't do much
It is also in a display group.
Thanks for the code. My first question is, are you intentionally creating a particle group versus just spawning individual particles? If this is intended to be like a normal liquid that might fill up a pool or similar, then you should probably spawn particles, not create a group. A group is intended for creating of, say, a “blob of gel”.
If the group IS what you want, I would suggest to continue tinkering with the parameters of the system, most specifically “radius”, “imageRadius”, and “density”. I tested your code, and adjusting these parameters definitely had an effect. So did “gravityScale”. Basically, at an overall level, liquid physics can be a tricky ordeal to get the setup and behavior exactly as you like, so I encourage you to keep experimenting.
Take care,
Brent
Yes I am intentionally creating a particle group. I’ve messed around with the parameters a lot and the small particles still move painfully slow compared to the other physics bodies. Changing physics.setScale() makes the other bodies move slower but it has a very little effect on the particles.
There are many factors which could be contributing to this. I think we’ll need to see some code around how you’re setting up the particle system and particles and other things you’re doing to them.
Remember to surround your code with “lua” tags for clarity:
[lua] ... [/lua]
Thanks,
Brent
Hi Brent, thanks for responding. It seems like a fairly normal implementation:
local water = physics.newParticleSystem( { filename = "drop.png", radius = 3, imageRadius = 4, gravityScale = 5,--doesn't do anything density = 1, } ) local watparam = { flags = { "water", "colorMixing" }, linearVelocityX = 10000000,--barely moves color = { 0, 0.3, 1, 1 }, x = 4200, y = 1000, lifetime = 50.0, radius = 30, } water:createGroup( watparam ) water:applyForce(10000000,0)--doesn't do much
It is also in a display group.
Thanks for the code. My first question is, are you intentionally creating a particle group versus just spawning individual particles? If this is intended to be like a normal liquid that might fill up a pool or similar, then you should probably spawn particles, not create a group. A group is intended for creating of, say, a “blob of gel”.
If the group IS what you want, I would suggest to continue tinkering with the parameters of the system, most specifically “radius”, “imageRadius”, and “density”. I tested your code, and adjusting these parameters definitely had an effect. So did “gravityScale”. Basically, at an overall level, liquid physics can be a tricky ordeal to get the setup and behavior exactly as you like, so I encourage you to keep experimenting.
Take care,
Brent
Yes I am intentionally creating a particle group. I’ve messed around with the parameters a lot and the small particles still move painfully slow compared to the other physics bodies. Changing physics.setScale() makes the other bodies move slower but it has a very little effect on the particles.