-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add random_query
example
#3704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add random_query
example
#3704
Conversation
} | ||
|
||
fn generate_pets(mut commands: Commands) { | ||
let pets = ['🐀', '🐄', '🐅', '🐇', '🐊', '🐓', '🐖']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small description nit, but this example is excellent. Very clear, and it's a very handy trick. Thanks!
Co-authored-by: Alice Cecile <[email protected]>
There doesn't seem to be anything bevy specific about this example, this is only showing how to use the IteratorRandom trait from rand. Do we really need an example for that? |
Point taken. We can integrate this into a game example as the need arises. Closing down this and the originating issue as this was much easier than I expected at first glance. |
Objective
Showcase how to select random elements from a query, as requested in #3652.
Solution
Add an example that shows how one can use
rand::seq::IteratorRandom::choose
andrand::seq::IteratorRandom::choose_multiple
to choose one or multiple random items from a query.