#Weird behaviour updating entities

7 messages · Page 1 of 1 (latest)

elfin oak
#

Hello I have an issue I don't understand...

            SystemSet::new()
                .with_run_criteria(FixedTimestep::step(TIME_STEP as f64))
                .with_system(spawn_bullets.before(apply_physics))
                .with_system(despawn.before(apply_physics))
                .with_system(apply_physics)```

On the `spawn_bullets` system I spawn some entities, but I don't set the SpriteBundle transform until `apply_physics` is executed... For a very small amount of time the spawned entities are rendered at the origin... But I thought those systems would run between rendering frames
wise girder
#

both spawn_bullets and apply_physics run in the same stage, but commands like spawn and insert are carried out at stage boundaries, that means that apply_physics first sees the bullets on the next frame

#

you could for instance schedule apply_physics for a later stage, which should fix this

#

so run in in CoreStage::PostUpdate for example

#
app.add_system_to_stage(CoreStage::PostUpdate, apply_physics);
elfin oak
#

thanks for this, I see but then it's strange that the rendering stage can see it

solar iris
#

That’s because by the time it’s rendered, the commands have been applied (as it occurs in a separate stage I believe)