Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by ansimuz

Hi,

What's the best approach to set gravity in the X axis. I am trying to simulate wind forces.

Thanks

1 decade ago by Joncom

Just one way you could do it:
/* Add the ability to be blown by wind to all entities. */
ig.Entity.inject({
    affectedByWind: false,
    update: function() {
        if(this.affectedByWind) {
            /* Manipulate velocity here. */
        }
        this.parent();
    }
});

1 decade ago by oronbz

Have you tried the Box2D plugin?

It has dual axis gravity (:

1 decade ago by ansimuz

@Oronbz

I rather don't use Box2d it will change the physics to the entire game.

@joncom

Thanks i will try it.

How would you apply the wind factor?

this.vel.x += ig.game.gravity * ig.system.tick * this.gravityFactor;

1 decade ago by Joncom

Quote from ansimuz
this.vel.x += ig.game.gravity * ig.system.tick * this.gravityFactor;
Sounds like you already figured it out.
Page 1 of 1
« first « previous next › last »