Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Despawning a Tiled map #566

Closed
treytencarey opened this issue Oct 10, 2024 · 1 comment
Closed

Despawning a Tiled map #566

treytencarey opened this issue Oct 10, 2024 · 1 comment

Comments

@treytencarey
Copy link

Hi, I'm using the Tiled example

// Load the Tiled map using the level file name
let map_handle: Handle<tiled::TiledMap> = asset_server.load(level_file_name.0.clone());

// Spawn the Tiled map bundle
commands.entity(entity).insert(tiled::TiledMapBundle {
    tiled_map: map_handle,
    ..Default::default()
});

When I despawn the original entity (also with despawn_recursive()) the map doesn't get removed with it

@rparrett
Copy link
Collaborator

You'll need to iterate through the entities in TileStorage and despawn them manually.

Some of the examples in this repo add spawned TileBundles as children of the Tilemap, which is also an option if you want to use despawn_recursive, but I personally don't think it's a good idea. But automatic despawning of tiles is something I'd personally like to see done. (See #582)

@rparrett rparrett closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants