Jump to content

Friction - Phaser 3


Recommended Posts

I'm making a game in phaser 3 using the arcade physics and I want the player to be able to move boxes. The player can move the boxes right now but they are to light. Can I solve this with friction between the boxes and the platforms, and if so how do I do that?

Here is my code:

platforms = this.physics.add.staticGroup();

platforms.create(180, 588, 'platform3').setScale(0.5).refreshBody();
platforms.create(580, 450, 'platform4').setScale(0.5).refreshBody();
platforms.create(980, 450, 'platform4').setScale(0.5).refreshBody();
platforms.create(1280, 450, 'platform4').setScale(0.5).refreshBody();

boxes = this.physics.add.group({
key: 'box',
repeat: 9,
setXY: { x: 100, y: 0, stepX: 180 }

this.physics.add.collider(boxes, platforms);
this.physics.add.collider(boxes, boxes);


Link to comment
Share on other sites

I must be doing something wrong. I added this code:

boxes.children.iterate(function (child) {

and it is still very easy for the player to move the boxes but when the box falls on top of the players head, the player falls through the ground. Is the code above the wrong way to set mass or am I doing something else wrong?

Link to comment
Share on other sites


  • Recently Browsing   0 members

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