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

Add an example teaching users about custom relationships #17443

Merged
merged 23 commits into from
Jan 20, 2025
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e3169b2
Expand module docs for `hierarchy` example
alice-i-cecile Jan 19, 2025
4cedb40
Export Relationship and RelationshipTarget in prelude
alice-i-cecile Jan 19, 2025
b008e3f
Add spawning section to example
alice-i-cecile Jan 19, 2025
fe46224
Fix metadata name for example
alice-i-cecile Jan 19, 2025
1a1a9f6
Fix up spawning
alice-i-cecile Jan 19, 2025
94bd55a
Improve warning in traversal methods
alice-i-cecile Jan 19, 2025
fb0dfab
Demonstrate cycle checking
alice-i-cecile Jan 19, 2025
15842f3
Show how to remove relationships
alice-i-cecile Jan 19, 2025
f89777e
Typo
alice-i-cecile Jan 19, 2025
7c25e04
Update examples README
alice-i-cecile Jan 19, 2025
13c193b
Consistently use relationship
alice-i-cecile Jan 19, 2025
a3093a4
Demonstrate how to mutate relationships
alice-i-cecile Jan 19, 2025
fbe500b
Better expect message
alice-i-cecile Jan 19, 2025
240462c
Revise example module docs to be more clear
alice-i-cecile Jan 19, 2025
7a8c66f
Merge remote-tracking branch 'alice-i-cecile/relations-example' into …
alice-i-cecile Jan 19, 2025
24b13d3
Use HashSet::insert more idiomatically
alice-i-cecile Jan 20, 2025
fd6ec8e
Merge branch 'main' into relations-example
alice-i-cecile Jan 20, 2025
4f29b6e
Fix comment about initial targeting setup
alice-i-cecile Jan 20, 2025
222d0e7
Merge branch 'main' into relations-example
alice-i-cecile Jan 20, 2025
8f2212c
Merge branch 'main' into relations-example
alice-i-cecile Jan 20, 2025
492bef4
Parent -> ChildOf rename
alice-i-cecile Jan 20, 2025
8ca1266
Fix EntityHashSet import
alice-i-cecile Jan 20, 2025
54fca60
Remove relationship traits from prelude due to subtle bugs created
alice-i-cecile Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Parent -> ChildOf rename
alice-i-cecile authored Jan 20, 2025
commit 492bef433fd5e51d029a6ad9b0b2414924ec90ff
4 changes: 2 additions & 2 deletions examples/ecs/relationships.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Entities generally don't exist in isolation. Instead, they are related to other entities in various ways.
//! While Bevy comes with a built-in [`Parent`]/[`Children`] relationship
//! While Bevy comes with a built-in [`ChildOf`]/[`Children`] relationship
//! (which enables transform and visibility propagation),
//! you can define your own relationships using components.
//!
//! We can define a custom relationship by creating two components:
//! one to store the relationship itself, and another to keep track of the reverse relationship.
//! Bevy's [`Parent`] component implements the [`Relationship`] trait, serving as the source of truth,
//! Bevy's [`ChildOf`] component implements the [`Relationship`] trait, serving as the source of truth,
//! while the [`Children`] component implements the [`RelationshipTarget`] trait and is used to accelerate traversals down the hierarchy.
//!
//! In this example we're creating a [`Targeting`]/[`TargetedBy`] relationship,