Hey! Been playing with bevy and learning rust. Was looking at the "Gltf master asset" example here: https://bevy-cheatbook.github.io/3d/gltf.html and that's kind of what i'm after, but not sure how to get the spawn_gltf_objects system to only run once after the gltf is loaded. I was looking for a 'remove_system' or something so it could remove itself after spawning the object but didn't see anything like that. Of course, I could keep track of if the object is spawned and do nothing if it's already spawned but that seems sloppy to have a system continue running every frame after it's completed its work. What's the suggested way to do something like this? Also I do like the systems approach so far, but in other settings you'd probably have something like a completion callback function that was called after the load finished, that seems more straightforward, is there something like that? Thanks!
#Callback or Schedule to run once when GLTF is finished loading?
6 messages · Page 1 of 1 (latest)
Dont know if that what you are searching but you could try with this
https://bevyengine.org/news/bevy-0-12/#one-shot-systems
But in general you could als just make it call once in startup or similar i guess
There is also this: https://github.com/nicopap/bevy-scene-hook but the best solution depends on what you're trying to do exactly.
Also note "that seems sloppy to have a system continue running every frame after it's completed its work" is not going to be the bottleneck for a Bevy game. So if it's the most ergonomic solution I would just go with that
Thanks! I saw the one-shot callbacks are perfect but I was not sure how to trigger them on scene loaded. That bevy-scene-hook looks like exactly what I need, I'll give that a try, and either use that directly or do something similar. I didn't consider the idea of stuffing the callback into a component like scene hooks is doing, that seems ideal as it could just remove that component when it's done.
And yeah, I'm not worried about a running the system itself, just more about holding on to the the state of an "is_spawned" flag and checking that every frame, with potentially hundreds of thousands of assets, or in a situation where you're loading and unloading zone, potentially unbounded. Still getting used to the flexibility of rust. Thanks!