Search code examples
rusttiledbevytmxtiledmap

bevy_ecs_tilemap unable to load tiled .tsx files


Background

I am working on a 2D game with Bevy. I want to use tilesets with tiled. I have found the crate bevy_ecs_tilemap and I looks promising for an easy solution. I have a file structure like this and want to load world.tmx

tilesets
├── floor
│   ├── ground.tiled-project
│   ├── ground.tiled-session
│   ├── ground.tsx
│   ├── Rules
│   │   └── autotile rules.tmx
│   ├── rules.txt
│   └── world.tmx
└── test.tmx

The problem

I followed the example supplied for working with tiled but when I run it I get this error WARN bevy_asset::asset_server: encountered an error while loading an asset: Could not load TMX map: Could not open 'tilesets/floor/ground.tsx'. Error: No such file or directory (os error 2) even though I does exist.

What I have tried

I have tried using a tilemap that does not depend on anything and it does work (that is what the test.tmx is)


Solution

  • I'm not sure if this is specifically your problem, but it seems that currently, loading of Tiled maps with external tilesets may not be supported by bevy_ecs_tilemap. There's some work being done to make it work, but it is currently not merged. See the comment at https://github.com/StarArawn/bevy_ecs_tilemap/pull/425#issuecomment-1537383275.

    A workaround would be to save the maps with the tilesets embedded, as was done with the examples shipping with bevy_ecs_tilemap. In Tiled, you can achieve this either by pressing the "Embed Tileset" button below the tileset view, or to export the map with the "Embed tilesets" export option enabled (recommended, if you want to keep sharing information stored in the tileset between multiple maps).