Jump to content

MoveTo doesn't work correctly


Recommended Posts

Hi, i'm having a little problem, and perhaps someone knows what to do.
i'm emitting particles with emitter.explode and afterwards (about a sec), i want to move them all to a certain point. they move indeed, but not to the point i want them to. instead, they're always a little bit too far to the right (always on the right).
i checked the destination.position multiple times, and it's correct, the particle bodys don't have any drag or something, i tried destroying them and give them a fresh new physics body, but still the same problem.
i checked the emitter, but couldn't find something suspicious, but i'm quite new to phaser, so perhaps i'm just missing something.
i'm using the arcade physics system.

Link to comment
Share on other sites

function addExplosiveEmitter(fieldName, key, frames, particleCount = 20, scale = 1, destination){
    let obj = this;
    let game = obj.game;
    let emitter = obj[fieldName] = game.add.emitter(0, 0, particleCount);
    emitter.makeParticles(key, frames);
    emitter.scale.setTo(scale, scale);
    emitter.minParticleSpeed.setTo(-350, 350);
    emitter.maxParticleSpeed.setTo(350, -350);
    emitter.minParticleScale = 0.3;
    emitter.maxParticleScale = 0.8;
    emitter.gravity = 250;
    emitter.emit = (lifespan) =>{
        emitter.explode(lifespan, particleCount);
            let timer = game.time.create(true);
            timer.add(1000, () =>{
                emitter.forEachAlive((child) =>{
                    game.physics.arcade.moveToObject(child, destination, 100, 1000);
    return emitter;


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...