[SOLVED] Local Particle Systems

Hello all,

Does anyone know how to make Playcanvas particle systems simulate locally? This is an option available in Unity, and I’m wondering if it’s possible to make this work in Playcanvas by somehow setting the velocity of particles to counteract world movement.

Basically in my scene I’d like to make it so that the exhaust coming from the ship engine doesn’t change as the ship moves around. Here’s a link to the project: PlayCanvas | HTML5 Game Engine

Thanks!

You can use local velocity instead of world velocity. There is a local velocity curve on the particle system component.

I tried that, and the particles are emitted correctly, but when the ship moves they’re still simulated in world space.

So I’m pretty sure you’d have a problem doing anything to the particle after emission - you could adjust for world velocity at the point of emission (to keep them stationary in world space if world space velocity is a constant) - but if you modify world velocity then it’s going to fall apart.

That’s the issue I’m aiming to resolve, is to keep the particles aligned in local space to the emitter regardless of world velocity. Digging through the engine source code I found a boolean:

pc.particleSystemComponent.localSpace

However, setting this value to true seems to produce strange results.

1 Like

To clarify, this is the effect I’m going for.

And this is the effect in practice when the ship is moving. If anyone has experience with particle systems in Playcanvas please let me know how I can achieve the first effect even when the ship is moving.

Can you simply use local velocity instead of world velocity?

That’s the thing, I am only using the local velocity graph. All values on the world velocity graph are 0 and the particle emitter is a child of the ship entity. I hope there’s not something obvious I’m missing here, but I can’t seem to figure it out.

If the ship is moving do you need any velocity? Or perhaps you need some fraction of the forwards velocity of the ship? So if the ship is going forwards a local velocity that is in the direction of movement?

1 Like

I tried that, modifying the world velocity graph to match the world velocity of the ship. The following code kind of works, however the particle system sometimes still glitches in odd ways:

LocalParticles.prototype.update = function(dt) {
        var vel = this.entity.parent.rigidbody.linearVelocity;
        var particlesVel = this.entity.particlesystem.velocityGraph;

        var xv = particlesVel.curves[0]; // x world velocity
        var yv = particlesVel.curves[1]; // y world velocity
        var zv = particlesVel.curves[2]; // z world velocity

        xv.get(0)[1] = vel.x; // Modifies the velocity of each
        yv.get(0)[1] = vel.y; //curve to match the ship's world
        zv.get(0)[1] = vel.z; //velocity.

        this.entity.particlesystem.velocityGraph2 = particlesVel;
}
2 Likes

It works okay for now, I’ll take a look through the particle system source code later to see if I can find what the problem is.