Add an example teaching users about custom relationships#17443
Merged
alice-i-cecile merged 23 commits intobevyengine:mainfrom Jan 20, 2025
Merged
Add an example teaching users about custom relationships#17443alice-i-cecile merged 23 commits intobevyengine:mainfrom
alice-i-cecile merged 23 commits intobevyengine:mainfrom
Conversation
Jondolf
reviewed
Jan 19, 2025
Co-authored-by: Joona Aalto <[email protected]>
Jondolf
reviewed
Jan 19, 2025
Co-authored-by: Joona Aalto <[email protected]>
Jondolf
reviewed
Jan 19, 2025
MinerSebas
reviewed
Jan 19, 2025
Co-authored-by: MinerSebas <[email protected]>
…relations-example
kristoff3r
approved these changes
Jan 20, 2025
nekosaur
reviewed
Jan 20, 2025
Co-authored-by: Kristoffer Søholm <[email protected]>
Carter0
reviewed
Jan 20, 2025
| // even though the entity itself is not yet instantiated in the world. | ||
| // This works because Commands will reserve the entity ID before actually spawning the entity, | ||
| // through the use of atomic counters. | ||
| let alice = commands.spawn(Name::new("Alice")).id(); |
Contributor
There was a problem hiding this comment.
Crazy question, but where is 'Name' coming from?
Member
Author
There was a problem hiding this comment.
This is a bevy_core component! It's quite nice!
Carter0
approved these changes
Jan 20, 2025
Contributor
Carter0
left a comment
There was a problem hiding this comment.
Minor comments, but overall I think It looks good!
alice-i-cecile
commented
Jan 20, 2025
alice-i-cecile
commented
Jan 20, 2025
Member
Author
|
I have no idea what's going on with CI here: I can't reproduce the failures locally or on |
mrchantey
pushed a commit
to mrchantey/bevy
that referenced
this pull request
Feb 4, 2025
…17443) # Objective After bevyengine#17398, Bevy now has relations! We don't teach users how to make / work with these in the examples yet though, but we definitely should. ## Solution - Add a simple abstract example that goes over defining, spawning, traversing and removing a custom relations. - ~~Add `Relationship` and `RelationshipTarget` to the prelude: the trait methods are really helpful here.~~ - this causes subtle ambiguities with method names and weird compiler errors. Not doing it here! - Clean up related documentation that I referenced when writing this example. ## Testing `cargo run --example relationships` ## Notes to reviewers 1. Yes, I know that the cycle detection code could be more efficient. I decided to reduce the caching to avoid distracting from the broader point of "here's how you traverse relationships". 2. Instead of using an `App`, I've decide to use `World::run_system_once` + system functions defined inside of `main` to do something closer to literate programming. --------- Co-authored-by: Joona Aalto <[email protected]> Co-authored-by: MinerSebas <[email protected]> Co-authored-by: Kristoffer Søholm <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
After #17398, Bevy now has relations! We don't teach users how to make / work with these in the examples yet though, but we definitely should.
Solution
AddRelationshipandRelationshipTargetto the prelude: the trait methods are really helpful here.Testing
cargo run --example relationshipsNotes to reviewers
App, I've decide to useWorld::run_system_once+ system functions defined inside ofmainto do something closer to literate programming.