# The best way to forbid rotation in Matter.js engine

**URL:** <https://phaser.discourse.group/t/the-best-way-to-forbid-rotation-in-matter-js-engine/14017>\
**Category:** Phaser 3\
**Created:** [February 21, 2024, 1:01pm UTC](https://phaser.discourse.group/t/the-best-way-to-forbid-rotation-in-matter-js-engine/14017 "2024-02-21T13:01:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![QuantumTopology](https://avatars.discourse-cdn.com/v4/letter/q/94ad74/32.png) [@QuantumTopology](https://phaser.discourse.group/u/QuantumTopology)\
**Post date:** [February 21, 2024, 1:01pm UTC](https://phaser.discourse.group/t/the-best-way-to-forbid-rotation-in-matter-js-engine/14017/1 "2024-02-21T13:01:38Z")

</div>

Hello. I am using matter.js. To forbid the rotation of the player, I set its angular velocity to zero in update(). Is this the standard way to do that ?

```javascript
update (time, delta)
{
    this.player.setAngularVelocity(0);
...
}

```

And when I move the layer, small gaps appear between tiles as the figure shows below. (Here I use some static shapes for collision detection). [In this topic](https://phaser.discourse.group/t/tilemap-gaps-when-camera-moves/1162), it’s metioned that this is the **pixel bleeding**. Is this still a problem is webGL ? I didn’t find this phenomenon in the examples provied by phaser3.  
 ![image](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/a/aca26ceafd15aeb6ddfba23cc3c5899f5f75ef54.png)

---

<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:** [February 21, 2024, 6:47pm UTC](https://phaser.discourse.group/t/the-best-way-to-forbid-rotation-in-matter-js-engine/14017/2 "2024-02-21T18:47:18Z")

</div>

I think people have used infinite angular inertia for that.

The tile problem can depend on the camera view sometimes.

---

<div class="post-metadata">

**Author:** ![QuantumTopology](https://avatars.discourse-cdn.com/v4/letter/q/94ad74/32.png) [@QuantumTopology](https://phaser.discourse.group/u/QuantumTopology)\
**Post date:** [February 21, 2024, 9:52pm UTC](https://phaser.discourse.group/t/the-best-way-to-forbid-rotation-in-matter-js-engine/14017/3 "2024-02-21T21:52:46Z")

</div>

OK, thanks.  
Then what shoud I do to the camera view ? I find this problem happens if I make the camera follow the player. If I just scroll the view like below, it won’t happen.

```javascript
this.cameras.main.setBounds(0, 0, map.widthInPixels, 600);
        const controlConfig = {
            camera: this.cameras.main,
            left: this.cursors.left,
            right: this.cursors.right,
            speed: 0.5
        };
        this.controls = new Phaser.Cameras.Controls.FixedKeyControl(controlConfig);

```

And I can only find a **inertia** property in the **player.body** , there is no angular inertia exists.  
 ![image](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/d/dec9ca269ebfb4a55f46635c24c21d59eab306ab.png)

---

<div class="post-metadata">

**Author:** ![QuantumTopology](https://avatars.discourse-cdn.com/v4/letter/q/94ad74/32.png) [@QuantumTopology](https://phaser.discourse.group/u/QuantumTopology)\
**Post date:** [February 22, 2024, 7:52am UTC](https://phaser.discourse.group/t/the-best-way-to-forbid-rotation-in-matter-js-engine/14017/4 "2024-02-22T07:52:01Z")

</div>

I find a phase3 example: Tilemap \> collision \> matter platformer modify map  
In this example, rotation forbidding is achieved by using the setFixedRotation() function on the sprite.  
Also, in this example, it uses a smoothMoveCameraTowards() function to make the camera follow the player. If I change it to

```javascript
this.cameras.main.startFollow(this.player);   

```

gaps also appear between tiles. So I guess this maybe a solution.
