this post was submitted on 05 May 2025
6 points (100.0% liked)

Bevy

322 readers
1 users here now

A community for discussion around the bevy game engine! https://bevyengine.org/

founded 1 year ago
MODERATORS
 

Hi!

I've been learning Bevy and LOVING IT, there's only one thing confusing me. Many components appear to be created magically even if not specified in the Bundle passed to commants.spawn.

For example, when I spawn just a Sprite component, the entity seems to automatically get a Transform component, even if I didn't give it one.

Similarly, this example spawns a Screenshot component, which apparently results in a Capturing component that can be queried later.

Are these "implicit" components documented somewhere? I took a short look at the TransformPlugin for example but I can't seem to figure out where these components come from.

Thanks y'all!

you are viewing a single comment's thread
view the rest of the comments
[–] codexarcanum@lemmy.dbzer0.com 3 points 1 week ago (1 children)

I'm not a bevy user but I'm writing a game in Rust so maybe I can help...

Looking at the docs for Screenshots in particular, it definitely looks like that system uses a few "marker" components to track state while making the screen capture.

Digging deeper into the source for the Screenshot component struct we can see what method it uses to attach these markers, and a little further into the function it uses the markers to find the screenshot entity and remove it.

I'm not sure about Sprite but probably something in the rendering system looks for and maybe applies a Transform when components are nested or added to world space? I also don't know if Bevy has a formal component hierarchy but something like that may be in play here with Sprite being a child or implementor of Transform, but that's just speculation on my part.

Hope that helps, maybe seeing how Screenshot does it will help you search in the source for Sprite to see where the Transforms are injected?

[–] PotatoesFall@discuss.tchncs.de 2 points 1 week ago (1 children)

Thanks so much!

I just managed to find the place where the Capturing component gets added, it's part of the extract_screenshots system in the ScreenshotPlugin.

For Sprite, another user found where this originates from, it's the require attribute.

[–] codexarcanum@lemmy.dbzer0.com 3 points 1 week ago (1 children)

Nice! Glad you worked it out!

I got so excited to see a Bevy post (in the Bevy community even!) I really want to see the gamedev community here pick up and exceed reddit, SO, and other company-owned gaming forums.

Ha, that's the reason I posted here. Full on expected to receive no reply for days so I was stoked to get an answer so fast!!