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 LazerFriends

Hello, I have what may be some n00b questions:

I am making a game where the player can push crates. How can I make it so the crates move slower when the player pushes them (like they're really heavy)?

Also, how can I prevent them from stacking when the crates run into each other?

And finally, is there a way to change the character animation when the player is pushing the crate?

See what I'm talking about here: http://bsmallbeck.com/impact/

Thank you!

1 decade ago by Joncom

Using a stronger physics engine like Box2D would let you set the mass of the boxes however you'd like (heavy in your case). Also, the boxes wouldn't stack.

Maybe use an animate function in your player, like so:
animate: function() {

    // Moving and touching crate. Use "push" animation.
    if(this.vel.x != 0 && this.isTouchingAnyCrate()) {
        this.currentAnim = this.anims['pushing-crash'];

    // Moving and not touching crate. Use normal "run" animation.
    } else if(this.vel.x !=0 && !this.isTouchingAnyCrate()) {
        this.currentAnim = this.anims['running'];

    // Not moving. Use idle animation.
    } else if(this.vel.x == 0) {
        this.currentAnim = this.anims['idle'];
    }

}

You would then need to make sure you call animate once per update.

1 decade ago by LazerFriends

Cool, I will check that out. Thank you.
Page 1 of 1
« first « previous next › last »