Trouv / bevy_ecs_ldtk

ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap
Other
664 stars 75 forks source link

Fix levels having incorrect `GlobalTransform` the first frame #140

Open johanhelsing opened 1 year ago

johanhelsing commented 1 year ago

The transform propagation system runs in the PostUpdate stage, so spawn the levels before PostUpdate so they have time to propagate, but after ProcessApi, so they'll be ready the next frame (assuming the LdtkWorldBundle will be spawned during the Update) stage.

I ran into this bug because in my game I scale the levels, and collision detection is therefore way off during the first frame sending my player character flying.

Trouv commented 1 year ago

I have to give this some thought. I'd prefer not to add another stage if possible, but I can't think of a way to off the top of my head. One reason I wanted to put level spawning before Update was so that users could flesh out entities using the "blueprint pattern" (querying for Added<EntityInstance> or Added<MarkerComponent>) during Update and not have any frame delay. Though, this seems like a reasonable concern too.