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 an Entity affecting other Entity behavior #328

Closed
ncallaway opened this issue Aug 24, 2020 · 10 comments
Closed

Spawning an Entity affecting other Entity behavior #328

ncallaway opened this issue Aug 24, 2020 · 10 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior

Comments

@ncallaway
Copy link
Contributor

ncallaway commented Aug 24, 2020

This is happening for me on bevy 0.1.3. The behavior appears to be introduced by commit 4eb437. The immediately prior commit (2dadc8) produces the behavior I expect.

Calling commands.spawn is causing one of my entities to disappear, and causes another entity to take on the Transform of the entity that disappeared. I suspect that some kind of entity ID or entity index is becoming incorrect.

Here is a sample of correct behavior with my code running with bevy#2dadc8:

entity-error-2dadc8

He is a sample of the incorrect behavior with bevy#4eb437:

entity-error-4eb437

Notice on the client that the cube disappears and that the plane appears to be getting the Transform that should be being applied to the cube.

Finally, on 4eb437 if I comment out spawning the messages that display on the sidebar in the client, the correct behavior is restored (except the client no longer has messages in the sidebar list)

// commands.spawn((Message::new(
//   &server_message.message,
//  &server_message.from,
//  server_message.ordinal,
// ),));

entity-error-4eb437-no-messages

Reproduction

This can be reliably reproduced by:

bevy = { git = "https://github.com/bevyengine/bevy.git", rev="2dadc86fb003f64db5e6870a327fd0ed969881e5" }
  • Run the server and in a separate shell the client cargo run --release --example testbed -- -s 127.0.0.1:12530, cargo run --example testbed -- -c 127.0.0.1:12541 127.0.0.1:12540 foo
    • Observe things working as expected (the messages appear in the sidebar, the server can move the cube with WASD and the cube position is replicated to the client)
  • Update cargo.toml to point bevy at the next commit:
bevy = { git = "https://github.com/bevyengine/bevy.git", rev="4eb437ab2e3c2b69ade01f3661fe128fe8027daa" }
  • Run the server and client again
    • Observe the issue described in the ticket: on the client the cube disappears and the plane takes the translation that should be applied to the cube.
  • Comment out the client's messages spawn in examples/testbed/net/mod.rs lines 127-131
    • Observe that the cube now behaves correctly on the client.
@ncallaway
Copy link
Contributor Author

Suggested Labels: bug | ecs

@Moxinilian Moxinilian added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events labels Aug 24, 2020
@sanisoclem
Copy link

sanisoclem commented Aug 25, 2020

not sure if this is related, but I experienced a similar thing where the material would "jump" between entities even if I don't have any systems that change the material, and each entity has their own material. Not working on materials atm so I haven't had the chance to investigate it yet.

flippin_material

This started happening after updating to 0ae74a4, I was using 2dadc86 before this.

@cart
Copy link
Member

cart commented Aug 26, 2020

I have a feeling that this is related to #299, which i am investigating now. Probably caused by #216

@ncallaway
Copy link
Contributor Author

ncallaway commented Aug 26, 2020

@cart Yea, that looks similar to the commit that introduced the issue for me (4eb437).

@sanisoclem Any chance you could try the two commits I identified as bad and good and see if your issue was introduced in the same commit?

@jngbsn
Copy link
Contributor

jngbsn commented Aug 26, 2020

Here's a minimal repro example, with some of my findings in case they help. https://github.com/jngbsn/bevy_entity_bug

@sanisoclem
Copy link

sanisoclem commented Aug 26, 2020

@sanisoclem Any chance you could try the two commits I identified as bad and good and see if your issue was introduced in the same commit?

yep, confirming that the issue only happen when using 4eb437a and up.

@cart
Copy link
Member

cart commented Aug 26, 2020

Cool cool. Thanks y'all! I'm working on a fix now.

@ncallaway ncallaway mentioned this issue Aug 27, 2020
@ncallaway
Copy link
Contributor Author

This issue no longer repros for me with master after the fix was merged!

@jngbsn @sanisoclem you might double check your test cases with master, but I suspect this is fixed.

@sanisoclem
Copy link

sanisoclem commented Aug 27, 2020

fixed for me as well, despawn works as expected too. Cheers!

@cart
Copy link
Member

cart commented Aug 27, 2020

Thanks for checking!

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

No branches or pull requests

5 participants