I have not found a good way to access and customize MatterBodyTiles that are added into the matter world from convertTilemapLayer. Please let me know if there is an existing alternative.
An easy solution seems to just return the new array of MatterBodyTiles instead of the matter world itself. https://github.com/photonstorm/phaser/blob/v3.50.0/src/physics/matter-js/World.js#L975
A more robust solution might involve creating a tilemapLayer equivalent abstraction for matterBodyTiles?
This could be useful for customizing tilemaps in the matter world. For example, customizing each tile as a sensor to detect collisions, but not actually colliding with other objects.
Right now I do this to get all the matterTileBodies.
const { TileBody: MatterTileBody } = Phaser.Physics.Matter;
const matterTiles = tiles.map(tile => new MatterTileBody(this.matter.world, tile));
More than happy to help with a PR for the easy solution, if the idea is acceptable.
I have not found a good way to access and customize
MatterBodyTilesthat are added into the matter world fromconvertTilemapLayer. Please let me know if there is an existing alternative.An easy solution seems to just return the new array of
MatterBodyTilesinstead of the matter world itself. https://github.com/photonstorm/phaser/blob/v3.50.0/src/physics/matter-js/World.js#L975A more robust solution might involve creating a
tilemapLayerequivalent abstraction formatterBodyTiles?This could be useful for customizing tilemaps in the matter world. For example, customizing each tile as a sensor to detect collisions, but not actually colliding with other objects.
Right now I do this to get all the
matterTileBodies.More than happy to help with a PR for the easy solution, if the idea is acceptable.