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 would be the best way to check and set an animation while the player is pushing an entity block?

1 decade ago by Joncom

Do you already have the code implemented that let's your player push entities?

Depending how you did it, maybe you have a boolean like like player.is_pushing. If so you could run a simple check in your player.update method:

if(this.is_pushing) this.currentAnim = this.anims.pushing;
else this.currentAnim = this.anims.standing;

1 decade ago by drhayes

Check out Entity.collideWith; it should give you what you want.

You could override it and check to see if the entity you&039;re colliding with is a block. You could then set #this.isPushing, possibly with a direction as well (so you know to flip the animation).

Once you know that the player has collided with a block entity you'll have to track the "pushing" state somehow. Maybe track the current pushed block on the player? You could make the player entity set the block's velocity as long as it is in the pushing state.

1 decade ago by ansimuz

I will check it out and let you know how it works.

Thanks
Page 1 of 1
« first « previous next › last »