# Emitter rotation (Particles)

Hi all!

In this example, I’m trying to rotate the particles along the y-axis along with the sphere. But nothing comes of it. How to do it correctly?

I believe it’s possible to get the particle system mesh and manipulate it as a regular mesh but I can’t put a finger on that in the doc.
ping @PatrickRyan

1 Like

You can rotate the shapeEmitter in the x direction

``````shapeEmitter.direction1 = new BABYLON.Vector3(1, 1, 0)
``````

See line 47

3 Likes

Yes, it looks good. But I need to rotate the shapeEmitter only on the y axis, creating a swirl effect

The shapeEmitter has no rotation but a direction. With a direction on the X axis, this amounts to rotating it on the y axis

1 Like

@Nawar, I’m not sure if this is what you are looking for, but if you want the system to rotate like the cylinder does, you can make it a local particle system. This means it will emit in the emitter’s local space rather than world space. You can see it in action at Emitter rotation | Babylon.js Playground (babylonjs.com). But ping me if this isn’t what you mean.

2 Likes

It’s very close! Now all the particles are spinning.

It is necessary that only newly created particles are subjected to rotation. Those particles that have lived for some time should remain in their places. Then, during rotation, such a curve should be obtained

The straight line is how the particle is positioned now. The curve is how they should be positioned. The red circles are particles.

@Nawar, the way the particle system works is that a particle is spawned within the emitter area - in your case at the edge of your cylinder emitter - and then follows the path set forth by the direction defined by the emitter. In your case, what is happening is that even though you are rotating the emitter, a particle spawns on the surface of the emitter (no matter what the current rotation of the cylinder is) and then follows the direction set by your code (0, 1, 0). So in this case it will always look as thought the emitter isn’t rotating because each particle is given a straight path to follow from a random location on a rotating emitter. Setting the system to local changes the frame of reference on that path to the emitter’s local space, meaning it will still travel in a straight path upwards, but not world up. This is why the particles rotate with the emitter.

What you are asking for is a particle that transitions from local space to world space. This is because you want the particle to rotate with the emitter at first, but as particle ages, it loses velocity on the rotation, but still follows a cylindrical path. This system simply isn’t set up to be able to do that.

You will likely need to use the Solid Particle System instead. You can still use quads and set them to billboard, but you will need to create their behavior. You could spawn the particles at a distance from the center of the system and then describe the path of the particles over time through rotation and translation that changes over the life of the particle. You will have far more control over your particles, but it comes at the cost of needing to create all of the behaviors by hand. However, with the motion you are describing, it seems as though this is the best path.

2 Likes

Okay guys, thanks for the replies. I’ll try SPS and play around with the directions, if something comes out of it, I’ll write about the results

1 Like