#bevy #ecs #gamedev #query-builder


Safe dynamic components API for Bevy

2 unstable releases

0.2.0 Apr 22, 2024
0.1.0 Apr 20, 2024

#565 in Game dev

Download history 251/week @ 2024-04-16 58/week @ 2024-04-23

54 downloads per month


98 lines



Add dynamic_components_plugin to your App:

use bevy_dyn_component::prelude::*;

This initializes the component type registry needed for some of the unsafe sections. After that, you can use the dynamic_component and insert_dynamic APIs:

struct DynamicMarker;

let marker0 = world.dynamic_component::<DynamicMarker>();
world.entity_mut(e).insert_dynamic(marker0, DynamicMarker);

The component ID can also be used in the query builder API.

Future of this crate

Now that Bevy supports dynamic components, it's likely that this crate will soon be obsolete. In the longer term, many of the things you can do with this crate is easier with relations.



Demonstrates basic usage of the library, how to create dynamic components with a layout matching an existing component, how to insert them into entities, and how to use them in the query builder API.


Demonstrates a simple way of using dynamic components as janky fragmenting relations. In my opinion, it doesn't work well as a general-purpose relations pattern, but for specific cases, it can be handy.

Bevy Version

bevy bevy_dyn_component
0.13 0.1-0.2


PRs welcome. If Bevy doesn't get good first-class support for this soon, I'll probably just keep updating this. It has missing APIs, for example, take_dynamic. I probably won't be adding this until I need it in a project, but I also won't hesitate to merge it in if someone else wants to tackle it.


~193K SLoC