I am aware that bundles are supposed to just be a simplification/easy spawning template, but i am consistently finding myself having to try to query for specific bundles rather than over a generic component. in this case, i want to specifically update the position of a sprite, but sprites come in SpriteBundles, and i have no idea how to filter the query to only get sprite transforms and not everything else. am i missing something? or am i just approaching the problem from the wrong perspective?
#how do you "query bundles"?
14 messages · Page 1 of 1 (latest)
bundle is just a collection of components, it basically gets unpacked and doesn't exist after you spawn the entity
as far as im aware, calling commands.spawn generates a single entity over the given components, does the spawn method just destructure the bundle into its components and then connect them together as an entity?
pretty much, yeah
so when i query for transforms, how would i specifically filter for entities that have sprites in them?
use a tuple with both transform and sprite, so Query<(&Transform, &Sprite)>
or whatever the components are called
so essentially, for every bundle, i look up some specific component it contains, then use that in the query?
just forget bundle exists
or several
alright
you query for an entity that has all components listed in a tuple, with an optional filter
If you don't care about the Sprite data, you could also do
Query<&Transform, With<Sprite>>
The second type parameter of Query lets you define query filters. https://bevy-cheatbook.github.io/programming/queries.html#query-filters