phaserjs / phaserjs/phaser

Rotating or flipping tiles in tiled doesn't work when using collisiondata and Matter physics

Open
#6,942 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🗺️ Tilemap
Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

Version

  • Phaser Version: 3.86.0

Description

I am using Phaser with Matter physics. I use tiled to create tilemaps and add collision data/boxes in this software. When flipping or rotating the tile in Tiled, Phaser gives an error.

Example Test Code

const map = this.game.make.tilemap({
    tileWidth: 16,
    tileHeight: 16,
    key: "MyMap"
});
map.addTilesetImage("tileset", "tileset", 16, 16);

const layer = map.createLayer(layer.name, ["tileset"]);
layer.setCollisionFromCollisionGroup();

this.matter.world.convertTilemapLayer(layer)

Additional Information

This code works fine when using a map without flipped tiles, it also works with flipped tiles that don't have collision data on them. But as soon you add a tile with collision data flipped (or rotated) it stops working.
image

A workaround is to add all tiles in each orientation in the tile editor, but I hope this issue can be solved in Phaser to keep tilesets smaller.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown tilemap setup, including a rotated or flipped tile with collision data, then trace the map.createLayer, setCollisionFromCollisionGroup, and matter.world.convertTilemapLayer entry points. Done means flipped and rotated collision tiles convert without an error while unflipped collision tiles continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.