# Friction Not Working

**URL:** <https://phaser.discourse.group/t/friction-not-working/5721>\
**Category:** Phaser 3\
**Created:** [April 1, 2020, 6:54am UTC](https://phaser.discourse.group/t/friction-not-working/5721 "2020-04-01T06:54:46Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [April 1, 2020, 6:54am UTC](https://phaser.discourse.group/t/friction-not-working/5721/1 "2020-04-01T06:54:46Z")

</div>

Hi.  
i am making a game .In my game scene i have a platform and 1 player .I am applying velocity on my player using this.physics.velocityFromRotation() and i am giving some random angle.Now the problem is when ever my player lands on a platform it is not stopping ,it is sliding very slowly. I applied friction to both platform and player using this.player.body.friction.x=1 and likewise to the platform.

i don’t know how to solve this issue.

Thank you

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [April 1, 2020, 2:52pm UTC](https://phaser.discourse.group/t/friction-not-working/5721/2 "2020-04-01T14:52:46Z")

</div>

Set the platform’s `friction.x` to 0.

---

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [April 22, 2020, 1:42pm UTC](https://phaser.discourse.group/t/friction-not-working/5721/3 "2020-04-22T13:42:49Z")

</div>

Thank you for the reply @samme  
this.Player.body.friction.x=0 //for the player  
this.bottom.body.friction.x=0 // for the ground.

still it is sliding on the ground.  
i am using arcade physics.

do you know what is the issue here?

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [April 22, 2020, 2:22pm UTC](https://phaser.discourse.group/t/friction-not-working/5721/4 "2020-04-22T14:22:39Z")

</div>

Forget friction, leave that alone.

If you want the player to slow down gradually, you can use drag. If you want it to stop immediately, you can zero the horizontal velocity.

---

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [April 23, 2020, 4:46am UTC](https://phaser.discourse.group/t/friction-not-working/5721/5 "2020-04-23T04:46:36Z")

</div>

ok. i will try that one.

do you know how to implement it?  
Any example will help me

thank you

---

<div class="post-metadata">

**Author:** ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)\
**Post date:** [April 23, 2020, 8:22am UTC](https://phaser.discourse.group/t/friction-not-working/5721/6 "2020-04-23T08:22:45Z")

</div>

this.Player.body.setDragX(0)  
and when you want to slow down the player  
this.Player.body.setDragX(200) // you need to search the good value

---

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [April 23, 2020, 10:26am UTC](https://phaser.discourse.group/t/friction-not-working/5721/7 "2020-04-23T10:26:24Z")

</div>

@BlunT76

not working. some where i am doing amistake.

I will create a simple project and i will try these solutions.

Thank you

---

<div class="post-metadata">

**Author:** ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)\
**Post date:** [April 23, 2020, 11:09am UTC](https://phaser.discourse.group/t/friction-not-working/5721/8 "2020-04-23T11:09:01Z")

</div>

Show us your code please

---

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [April 24, 2020, 3:42am UTC](https://phaser.discourse.group/t/friction-not-working/5721/9 "2020-04-24T03:42:38Z")

</div>

//for player

this.Player= this.physics.add.sprite(750/2,1334-500,‘player’)

```
           this.Player.setScale(0.35,0.35)
          this.Player.setCollideWorldBounds(true);
        this.Player.setMass(10)
        this.Player.body.friction.x=0  
       //this.Player.body.allowDrag= true;
        this.Player.body.setDragX(0)

```

//for ground  
//bottom

```
           this.bottom = this.physics.add.sprite(750/2,1335,'boundary')   
           this.bottom.displayWidth=750;this.bottom.displayHeight=100
           this.bottom.setImmovable(true)
           this.bottom.body.allowGravity=false
           this.bottom.setVisible(false)
           this.bottom.body.friction.x=0 
          this.bottom.body.setDragX(200)

```

then added collider  
this.physics.add.collider(this.Player, this.bottom);

---

<div class="post-metadata">

**Author:** ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)\
**Post date:** [April 24, 2020, 4:23am UTC](https://phaser.discourse.group/t/friction-not-working/5721/10 "2020-04-24T04:23:58Z")

</div>

You doesn’t define what happens when they collide:

```javascript
this.physics.add.collider(this.Player, this.bottom, function(player, bottom) {
    player.setDragX(200);
}, null, this;

```

Let me know if it works better

---

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [April 28, 2020, 10:46am UTC](https://phaser.discourse.group/t/friction-not-working/5721/11 "2020-04-28T10:46:31Z")

</div>

Thank you.  
yes. it is working now. i set the dragx to 500.

how to reset the value to normal after collision?

and what is the initial dragX value?  
Thank you

---

<div class="post-metadata">

**Author:** ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)\
**Post date:** [April 28, 2020, 11:45am UTC](https://phaser.discourse.group/t/friction-not-working/5721/12 "2020-04-28T11:45:03Z")

</div>

dragX default value is 0.  
To reset the value you can use a timer

```javascript
this.physics.add.collider(this.Player, this.bottom, function(player, bottom) {
    player.setDragX(500);
    this.time.addEvent({
        delay: 500, // in ms
        callback: () => this.player.setDragX(0); // called when delay is reached
    });
}, null, this;

```

---

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [April 28, 2020, 11:58am UTC](https://phaser.discourse.group/t/friction-not-working/5721/13 "2020-04-28T11:58:32Z")

</div>

> [@BlunT76](#):
>
> this.time.addEvent({ delay: 500, // in ms callback: () =\> this.player.setDragX(0); // called when delay is reached });

Thank you. i will check it now.  
i am new to phaser.  
please suggest me some tutorials.  
And i am actually building a fb instant game.i am facing issue with resolution .game is not fitting with the mobile screen.  
suggest some content for that also.  
Thank you

---

<div class="post-metadata">

**Author:** ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)\
**Post date:** [April 28, 2020, 12:10pm UTC](https://phaser.discourse.group/t/friction-not-working/5721/14 "2020-04-28T12:10:59Z")

</div>

For mobile resolution look at game config , scale parameters.  
For tutorials, google will give you better results than me, i usually use the docs and the official phaser 3 examples. And when it is not enough i search with google. It really depends on the kind of games you’re making.

---

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [April 28, 2020, 1:21pm UTC](https://phaser.discourse.group/t/friction-not-working/5721/15 "2020-04-28T13:21:14Z")

</div>

Thank you bro.

you helped me alot 🙂
