Christian981 Posted November 16, 2018 Share Posted November 16, 2018 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 More sharing options...
samme Posted November 16, 2018 Share Posted November 16, 2018 Not friction, but try increasing the boxes' mass. Christian981 1 Link to comment Share on other sites More sharing options...
Christian981 Posted November 16, 2018 Author Share Posted November 16, 2018 I must be doing something wrong. I added this code: boxes.children.iterate(function (child) { child.setMass(10); }); 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 More sharing options...
samme Posted November 16, 2018 Share Posted November 16, 2018 That looks right. You can also use mass in the group create config. You might have to use a custom collision callback for the pushing part. The fall-through is a drawback of Arcade Physics. It doesn't stack objects well. And it may be worse here because the larger mass moves the player more during the collision.. Link to comment Share on other sites More sharing options...
Recommended Posts