Creating a particle effect at runtime

Hi,
I’m new to play canvas and I’m trying to make a bomberman game remake.
I’m trying to place a particle effect on screen whenever my bomb is about to explode.
Generally i would like to replace my bomb entity with an instantiation of an explosion entity.
The explosion particle effect i’m trying to make is a cross explosion similar to that of the original bombermanGames.
I somehow got an effect similar to this by using the particle_emitter.js the one referred to in the forums.
Now i’m trying to instantiate that explosion like how i instantiate bombs but the explosion doesn’t show up.

// In my inputs my character drops a bomb whenever space is pressed
// I created an entity called ExplosionParticles in the heirarchy and just disabled it
// I referenced that to clone new explosion particles
// when i attach a model on my empty entity and run it i see that the clone entity is actually being placed in the world.
// my problem is the particle effect is not showing unlike the bomb
// Is there anything specific i should know about this matter?

// Here’s the bomb script
pc.script.attribute(‘materials’, ‘asset’, [], {type: ‘material’} );

pc.script.create(‘Bomb’, function (context) {

// Creates a new Bomb instance
var Bomb = function (entity) {
    this.entity = entity;
};

Bomb.prototype = {
    // Called once after all resources are loaded and before the first update
    initialize: function () {
        this.entity.collision.on('collisionstart', this.onCollisionStart, this);
        this.mat3 = context.assets.getAssetById(this.materials[2]).resource;
        this.mat2 = context.assets.getAssetById(this.materials[1]).resource;
        this.mat1 = context.assets.getAssetById(this.materials[0]).resource;
        this.entity.model.model.meshInstances[0].material = this.mat1;
        this.soundInstance = 0;
        this.bombTimer = 5;
        this.explode = context.root.findByName('ExplosionParticles');
    },

    // Called every frame, dt is time in seconds since last update
    update: function (dt) {
        this.bombTimer -= dt;
        if(this.bombTimer >= 4 && this.bombTimer < 5){
            this.entity.model.model.meshInstances[0].material = this.mat1;
            
        }
        else if(this.bombTimer >= 3 && this.bombTimer < 4){
            this.entity.model.model.meshInstances[0].material = this.mat2;
        }
        else if(this.bombTimer >= 2 && this.bombTimer < 3){
            this.entity.model.model.meshInstances[0].material = this.mat3;
        }
        else if(this.bombTimer >= 1.5 && this.bombTimer < 2){
            if(this.soundInstance === 0){
                this.entity.audiosource.play('BombExplosion');
                this.soundInstance = 1;
                var explosion = this.explosion.clone();
                explosion.setPosition(this.entity.getPosition());
                explosion.rigidbody.syncEntityToBody();
                context.root.addChild(explosion);
            }
        }
        /*else if(this.bombTimer >= 1 && this.bombTimer < 2){
            this.entity.audiosource.play('Big Explosion');
        }*/
        else if(this.bombTimer <= 0){
            this.entity.destroy();
        }
    },
    
    onCollisionStart: function(result){
        if(result.other.getName() === 'Ground'){
            this.entity.rigidbody.linearVelocity = pc.Vec3.ZERO;
            this.entity.rigidbody.angularVelocity = pc.Vec3.ZERO;
            this.entity.rigidbody.angularFactor = pc.Vec3.ZERO;
        }
        else
            return;
    }
};

return Bomb;

});

Thanks in advance!

Hi there!
Wow, you’ve made great progress with your game so far. The core elements of Bomberman are pretty much there.

So you/re currently using a particle system that exists in the engine but was never officially released. A few projects still use it, despite it not being official API. This particle system implementation had a number of problems. The main thing was that there was never an accompanying editor built for it.

However, I can break some totally awesome news to you now. :smile: We are close to deploying a really cool new particle tool. Here’s a visual preview of an effect made in it:

https://vine.co/v/OhbLH7b65EI

As it happens, we are looking for beta testers. Would you like to volunteer? You can try building your explosion effect with it. All we ask is that you give us some feedback on what you do and don’t like about it. How does that sound? If you want to try it out, we should be able to whitelist you and give you access by the end of tomorrow.

Yeah that’s great news. That would really healp a lot of play canvas users if a particle system was part of the api :smile: It’ll be my pleasure to test the new particle system. I’ll volunteer.
This is what my game looks like now. If only that blue cross you see in the image are particles… lol :smile: