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

Spawning a child entity in or after POST_UPDATE won't be properly registred as child of the parent #891

Closed
lassade opened this issue Nov 19, 2020 · 5 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior

Comments

@lassade
Copy link
Contributor

lassade commented Nov 19, 2020

Bevy version
0.3 (commit fae6287)

Operating system & version
Fedora 31

What you did
Spawn a child entity during or after POST_UPDATE stage
You should only use the spawn function and then manually add the parent ...

What you expected to happen
The entity GlobalTransform should reflect it's parent movement

What actually happened
The entity was sitting still in the origin (0, 0, 0) while it's parent was moving around

Additional information

@Moxinilian Moxinilian added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events labels Nov 19, 2020
@svents
Copy link
Contributor

svents commented Nov 21, 2020

I think this happened in the following commit: 43aac1a

In the parent_update_system (which runs in POST_UPDATE) a query filter was added like this:
mut changed_parent_query: Query<(Entity, &Parent, Option<&mut PreviousParent>), Changed<Parent>,>,
Changed is reset after each frame, so the entities in question are no longer picked up in the next frame as before. I think removing Changed here does no great harm, because the system has to verify anyway that the value actually changed (Changed only tracks mutable access).

@lassade
Copy link
Contributor Author

lassade commented Nov 21, 2020

I think you are right but I also thinkg this pr #907 shouldn't be the right call for it. I think the parent_update_system should instead run at the end of each stage just like the command buffer;

@cart
Copy link
Member

cart commented Nov 22, 2020

I think the parent_update_system should instead run at the end of each stage just like the command buffer;

It would fix this specific issue, but I would very much prefer to not run the same system in every stage. That seems unnecessary and a bit hack-ey. Ideally I think it makes more sense to make Parent/Child updates transactional to avoid the issue entirely (or remove the Changed filter like #907 does, which is probably the better short term solution).

@lassade
Copy link
Contributor Author

lassade commented Nov 23, 2020

Yeah, I guess the perf won't take that big of a hit

@alice-i-cecile
Copy link
Member

If #68 is fixed this should be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants