bevy_ecs_tilemap
bevy_ecs_tilemap copied to clipboard
AnimatedTile add/remove bug
[dependencies]
bevy = { version = "0.12.1", features = ["wayland"] }
bevy_ecs_tilemap = { git = "https://github.com/StarArawn/bevy_ecs_tilemap", branch = "main" }
Hello! Enjoying using bevy_ecs_tilemap for a game jam, and thanks so much for your hard work.
I think I may have found a related bug to #474. I've been adding and removing AnimatedTile to support various action animations on a tile. (It's possible this isn't great practice, it's "jamcode" so we'll leave efficiency aside for now!) However, I notice that some of the time the animation doesn't stop when the component is removed.
I'd be happy to submit a PR but I'm a little new to the library, and not completely certain what's causing this inconsistent behaviour. I note that the workaround described in #473 solves the issue:
commands
.entity(character_entity)
.remove::<AnimatedTile>()
.insert(SeekingStorage { tile_pos: None });
if let Ok((_, mut color)) =
character_animation_q.get_mut(character_entity)
{
color.set_changed();
}
So presumably removing AnimatedTile just needs to trigger changed state? If you can point me in the right direction, I can have a crack at fixing it.
Thanks for the report. Glad that workaround worked for you.
So presumably removing AnimatedTile just needs to trigger changed state? If you can point me in the right direction, I can have a crack at fixing it.
Sounds about right to me. I think this might be slightly more involved than the previous fix. It has been a while since I've looked at this code and I'm 100% sure this would work in an "extract system" but at a glance, I would try:
- Splitting
changed_tiles_queryinto- A query that just grabs the
Entitywith the same big "or changed" filter. - A separate query that actually retrieves data
- A query that just grabs the
- Adding an
Extract<RemovedComponents<AnimatedTile>>system param - Use
iter_manyto grab data tile data for entities that were either changed, or had that component removed.
Thanks! I'll take a look after recovering from the jam :laughing: