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 ={
key: 'box',
repeat: 9,
setXY: { x: 100, y: 0, stepX: 180 }

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


Share this post

Link to post
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?

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.