Path: blob/main/release-content/release-notes/generic_component_propagation.md
6592 views
---
---
When working with large hierarchies of game objects, coordinating the state of the entire tree can be frustrating. Bevy uses this pattern when working with transforms and visibility internally, but users have had to reinvent the wheel every time they wanted to use similar patterns.
While this pain was most acute when working with RenderLayers
, this pattern is more broadly useful, and has been exposed to end users in the form of the HierarchyPropagatePlugin
. You might use this for synchronizing color and alpha values for "ghost" versions of previewed buildings, ensuring that all of the parts of a model are on the same render layer, or propagating font styles.
This plugin has three generics:
C: Component
: the type of component that should be propagatedF: QueryFilter=()
: if set, only entities which match this filter will be affected by propagationR: Relationship = ChildOf
: the type of tree-like relationship to propagate down
Each copy of this plugin will propagate components of type C
down the hierarchy, along all entities which match the query filter of type F
. With this plugin enabled for C
, you can add a Propagate<C>
component to add new components to all children, add a PropagateStop<C>
component to stop propagation, or even use PropagateOver<C>
to skip this entity during propagation.
This is a very general tool: please let us know what you're using it for and we can continue to add examples to the docs!