# How does the friction work?

**URL:** <https://forum.makecode.com/t/how-does-the-friction-work/39897>\
**Category:** Help\
**Created:** [October 21, 2025, 3:43pm UTC](https://forum.makecode.com/t/how-does-the-friction-work/39897 "2025-10-21T15:43:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stickman4269](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/stickman4269/32/23582_2.png) [@Stickman4269](https://forum.makecode.com/u/Stickman4269)\
**Post date:** [October 21, 2025, 3:43pm UTC](https://forum.makecode.com/t/how-does-the-friction-work/39897/1 "2025-10-21T15:43:49Z")

</div>

I’ve used it a few times and it works well enough at stopping things, but how does it actually work? is it a flat deceleration? is it proportional? is it exponential? how does it work?

---

<div class="post-metadata">

**Author:** ![spookmakers](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/spookmakers/32/35968_2.png) [@spookmakers](https://forum.makecode.com/u/spookmakers)\
**Post date:** [October 22, 2025, 5:35pm UTC](https://forum.makecode.com/t/how-does-the-friction-work/39897/2 "2025-10-22T17:35:23Z")

</div>

![](https://kagi.com/proxy/300px-Good_Question.jpg?c=vImeDwtZh3Gg4A-l10QPw4HlAP1Gkfn4NmkHP6fwX-Ft5PYGzt1d5JlQkdcj-WoSwmnqolLzZfwvGIL0RVNEPv2So83g4lGtTgDmJbOTF3xgIByy01B3heB84_4Y4PqeC9mVqNpwCIj3BZEYKz1zIw%3D%3D)

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [October 22, 2025, 8:49pm UTC](https://forum.makecode.com/t/how-does-the-friction-work/39897/3 "2025-10-22T20:49:59Z")

</div>

![Screenshot 2025-10-22 at 12.31.02 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/f/bffe4c08f1651cdd2d352333fefa3d46ec3b11b5.png)  
Here is the code for the X half of the equation. Basically it works as follows.

This code is essentially doing the same thing as the acceleration code, which is also in that screenshot. It’s as if you have a loop that applies acceleration in the direction opposite of the player’s movement direction. In fact, here’s a test where one sprite has friction 50, and the other has acceleration -50, and you can see they move the exact same until they reach 0 speed!

> **[testing](https://arcade.makecode.com/S82259-03001-04572-33975)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.
