Closed thombruce closed 9 months ago
I wonder if we might want this pre-v0.1 for enemy spawning...
Enemies should be spawned on some kind of timer (maybe semi-random) at some position a certain distance from the player.
It's that position I wonder if the crate would help with...
We could just use the rand crate already installed, and get a random distance and a random rotation for spawning the enemy relative to the player.
Perhaps consider implementing with the current rand crate, playtesting, and then adding some determinism to see if it plays better with that slight predictability. However...
Question whether or not we want the player to be able to predict the enemy encounters... because that's what introducing determinism would mean.
Also note the distinction between true randomness and chaos. Chaotic systems are inherently unpredictable but emerge from deterministic rules - even with deterministic values, with enough complexity the system could be chaotic and impossible to predict.
I'm adding a little bit of randomness to the game in order to achieve a small amount of simulated inaccuracy or bullet spread when weapons are fired. I'll add the commit responsible for this here once it's pushed. As promised: 8aa2c14d46445ffceaf88e5295058e9416537c73
To do this, I am currently using the Rust rand crate: https://crates.io/crates/rand
This allows me to generate a random number from a range like so:
Note: The same library does have a
SeedableRng
class for deterministic randomness which I am not currently using.The point of this issue is mainly to ask the question: Should I be using bevy_rand instead? https://github.com/Bluefinger/bevy_rand
Near as I can tell, the main advantage that bevy_rand offers is to add the deterministic seed to a resource (these seeds can also be global or - if I'm reading right - adding to specific entities, so that they have independent, yet still deterministic, randomness).
The docs note that you should take care in how systems are grouped (accessing different components/resources so that they can run in different threads simultaneously) and ordered (ensuring that deterministic randomness provides the same results for each system each time, rather than retrieving values in a different order).
I am sure that we want deterministic randomness eventually, and this crate seems to ease that a little.
Do more research and maybe experiment to determine the utility of the crate vs the current implementation (and the
SeedableRng
it provides).Also look at the difference between rand and rand_core, which the bevy_rand crate lists as optional (either or) dependencies. We currently have rand installed.