Rocket Thruster Effect With Particle Systems

Hey everyone,

I want to build a rocket thruster effect with particle systems for my game. I’ve been able to find and tweak a particle effect to my liking, which works when the ship is static, but the particles don’t follow the ship very well when the ship is in motion. Please find a video of the issue here. This is the project link(After launching the scene, use the arrow keys to strafe and Z to boost to see the problem).

How should I approach this?

Hi @DevilZ,

Yes, that’s a difficult problem to approach. Check this older forum thread, it contains insight on possible solutions:

2 Likes

Thanks, I’ll try it out and revert soon!

@Leonidas I’ve tried something similar to what was suggested in the post, but I didn’t quite get the desired result, it seems much the same. This is what I’ve tried -

var Emitters = pc.createScript('emitters');


// initialize code called once per entity
Emitters.prototype.initialize = function() {
    this.player = this.entity.parent;
    this.previousPosition = new pc.Vec3();
    this.velocity = new pc.Vec3();
    this.emitters = this.entity.children;
};

// update code called every frame
Emitters.prototype.update = function(dt) {
    let position = this.player.getPosition();
    this.velocity.sub2(position, this.previousPosition);

    let start = this.emitters[0].getPosition();
    for (let i=1; i<=3; i++) {
        start = start + this.velocity;
        this.emitters[0].setPosition(start);
    }
    
    this.previousPosition.copy(position);
};

// swap method called for script hot-reloading
// inherit your script state here
// Emitters.prototype.swap = function(old) { };

// to learn more about script anatomy, please read:
// https://developer.playcanvas.com/en/user-manual/scripting/

Hi @DevilZ! I’m not sure, but If you only use local velocity for the particle system, you can just rotate the entity of it, based on the rotation of the rocket. (If necessary I would use a parent entity to make sure the pivot is in the correct position).

1 Like

Alright, I see the rotation is not the problem, but maybe if you use that solution it gives you a better effect as well.

1 Like

Thanks for that @Albertos, is there any example project of this you can share? I haven’t worked too much with particle systems, so it would be great if there is an example of this.

I found a demo project that is exactly what you need! Use your mouse or finger to see the cool effect! :fire:

https://developer.playcanvas.com/en/tutorials/flaming-fireball/

@Albertos even here the particles seem to be separating in a similar way like they do on the rocket thruster, and then come back together when the mouse is stationary. Perhaps the effect is not as obvious since the fireball isn’t moving as quickly as the spacecraft is.

Yes, that’s something I don’t understand either. In the project below I tried to solve this, but unfortunately without success.

https://playcanvas.com/project/853649/overview/flame

The problem was resolved with this thanks to @yaustar’s advice. Hopefully fine tuning other attributes will help me achieve the final effect. I hope this helps those of you who are looking to have a similar effect!