Scroll particles along with the particle system in Liquid Fun.

Hi,

I am currently working on a 2d side scrolling game and using liquid fun to portray water particles leaking from a broken pipe. I created a particle system and inserted it into the group that scrolls. Though the particle system(emitter) is scrolling as expected, the particles emerging from it are not respecting the scroll. I see no way of assigning a separate display group to the particles and assumed that they’ll be spawned in the same display group as the emitter which indeed seems to be the case. But for some reason, once spawned, the particles don’t scroll and as a result their movement is terribly affected. Any ideas how I can prevent this from happening?

Hi, 

i know the standard particle system support this but havent tried the liquid fun stuff yet.

However, a quick search seem to indicate that you need to create them as a group (unlike inserting into a display group) to give them added properties, could be wrong though :slight_smile:

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

You can’t add individual particles to separate display groups. Instead, you have to insert the entire particle system into a display group and it’ll work.
 

Thanks for your time. The group indicated in the above mentioned documentation refers to the region/area in which you’d want to create the particles. It could be circular, rectangular or of any other shape. My concern here is about assigning a display group to each individual particle, emitted by the particle system, to make them scroll along with rest of the environment. 

Thats not what he is asking and that doesnt work for either particle systems.

in the Corona API particle system, the particles can be locked relative to emitter or not.

He is looking for a similar “lock” for liquid fun.

particles themselves dont have properties in Corona, except those inherited from emitter, so unless particle fun will let you lock the particle position to the emitter position, I dont think this can be done. It’s all about the emitter.

Yeah exactly. This particle lock thing is what I’m after. So I take it you’re not sure if LiquidFun has that feature of locking particles relative to the emitter?

Sorry if I missed something. I thought the question was simply how to make the liquid fun particles scroll like this.

Well yeah this is what I want. I’ll have a look at the code and respond shortly.

heh! the handiness of someone who actually tried it.

so, as xedur has shown, is just a matter of inserting the emitter into a displaygroup.

Yeah, this is something that I’ve done in several past projects, so I was sure that I had misunderstood the question when I was told that what I just explained can’t be done. :smiley:

Yeah looks you you were indeed right. The display group of particles is same as that assigned to the emitter. But I’m afraid I’m still not 100% convinced with this system. It somewhat looks like the physic particles are not respecting the change of position w.r.t. its environment. I’ve made some changes in your code to demonstrate it. 

when i run this project in the simulator on my pc, it all looks fine to me.

have you tried it on a device or only in simulator on pc/mac?

Just on mac. Did you try running the code that I posted? Try moving the particle source, you’ll notice that the behaviour of particles doesn’t change. I might be missing something, could be something straightforward but I wish to clear all kinds of doubts to save the effort for future viewers.

i sometimes had issues like that with my previous monitor, i guess related to refresh rate.

it had some weird 59 fps as max instead of 60.

my current one has no issues, but its a high end device capable of running up to 165 fps in g-sync, although i doubt those abilities get triggered for running the simulator.

yes i tried your modified project and all works fine here.

That’s strange. Anyway thanks for your time. I’ll have a harder look and dig deep into my code to figure out the problem. :)  

@leokarun, the problem in your modified code is that you changed every other display object’s group, but you didn’t change the floor’s group.

But floor is a physical object and it is also evident that actually the floor is at the bottom but the particles are detecting it way above. Shouldn’t the particles respect the physical object nevertheless? For instance if I am to move only the water source and not the floor, isn’t that achievable?

That’s because of how the box2d physics work.

When you turn a display object into a physics object, the physics engine “owns” the object and has its own rules about the object. The engine also assumes that the anchor point is at the center of the object.
https://docs.coronalabs.com/api/library/physics/addBody.html#gotchas

The underlying physics bodies don’t actually move like they might seem to when you move the display group around.
 

It is valid to move, scale, or rotate a series of groups in unison or lock-step as long as these groups maintain the same coordinate origin, angle, and scale. However, if groups are moved, scaled, or rotated independently of each other, the Box2D collision system will consider the physics bodies to be in their original state, not as they appear as a result of transforming the group.
https://docs.coronalabs.com/guide/physics/limitations/index.html