You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example i try to access a component by entity, but it fails as the archetype_access for the system is not updated after the spawning of the entity with (A,C)
use bevy::prelude::*;fnmain(){App::build().add_default_plugins().add_startup_system(startup_system.system()).add_system(normal_system.system()).run();}fnstartup_system(mutcommands:Commands){
commands.spawn((B(None),));}#[derive(Debug)]structA;structB(Option<Entity>);structC;fnnormal_system(mutcommands:Commands,a:Query<&mutA>,mutb:Query<&mutB>){formut b in&mut b.iter(){match b.0{Some(entity) => {dbg!(a.get::<A>(entity)).unwrap();}None => {let new = commands.spawn((A,C)).current_entity().unwrap();
b.0 = Some(new);}}}}
output
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: CannotReadArchetype', examples/ecs/startup_system.rs:27:42
Something like this fixes it, but im not sure if this is the right solution. (should probably be fixed in parralel_executor). It you could give me some pointers i would love to make a PR.
@mockersf yea that makes a lot of sense. in the original code the archtype (A, C) does not exist yet, and after creating the new archetype in the system archetype_access is not updated. But if you add the archetype at the start then it will be set correctly the first time. still a good workaround for the crash
In the example i try to access a component by entity, but it fails as the archetype_access for the system is not updated after the spawning of the entity with
(A,C)
output
Something like this fixes it, but im not sure if this is the right solution. (should probably be fixed in parralel_executor). It you could give me some pointers i would love to make a PR.
The text was updated successfully, but these errors were encountered: