Already looking forward to part 3! Really pleasant to watch the video, the code snippets are really nice presented. Thank you for all the time you invest to make them look polished
Awesome, more .11 Bevy! I hope the new job is treating you well (think I remember you saying you were switching a while ago). If onboarding is going well, and you have a good team, then that means more Bevy content for us :) .
Every video I get a little more comfortable reading Query etc. I hope eventually it will all just click for me and I can work with Bevy queries with the same confidence I write MonoBehaviour code in Unity.
What is the practical difference at 4:00 between using a filter and a tuple of components? So for example, what is the difference between Query for the pigs versus Query for the player? To me both seem to return a set of component tuples (ie entities) that only have both of the specified components.
The With version doesn't give read access to Pig. So we're not reading pigs value, just ensuring the entity has a pig component. Practically this means another system can be mutating pig components while this runs but it's also good for expressing that this system doesn't depend on the value of pig. It's a good practice to get the minimum of mutable/read only/with that you need
Since using commands to spawn stuff doesn't actually happen when its called but rather sometime at the very end of each tick I personally like to emit events, e.g. as it's a very common and often generic thing. A Spawn event with a position and texture attribute is a generic way to handle this case for example
I thought that I have understood the concept of ECS in bevy. So far, the my understanding is: [Entity] a unique identifier that may or may not attached to a Component or multiple Components. It does not contain any data, it is like an index or identifier to a Component or a bunch of Components shall I say. [Component] the data structure defined by developer to be used in the game. This data structure is meant to be registered in the StartUp schedule, which then later can be queried in the Update schedule. Suppose, two instances of the same type i.e (a struct) are meant to be queried in the Update schedule, we must create two different Components instead of one. If only one Component is defined i.e derive from Component class or interface (idk), the instances of that Component cannot be queried in the Update schedule. So, in ECS, multiple instances of a Component are absolutely obsolete. [System] a function that is defined with a set of parameters defined by bevy ecosystem that we want to use in a particular function/system. For example, we might need instance of `Command` structure. So, we declare it in the parameter. With the help of AI, it says i have 235 entities. what are the ways to reduce the entity number. I wanted to create a 4 player chess game
For components you can create new entities with your components during update as well. Components are attached to entities so you can have many copys of each component but only one for each entity. Resources are what's constrained to 1 globally. For your chess game that's a totally reasonable number of entities. Bevy can handle much more than that without any problem
the `commands.spawn()` method in the docs it says, it accepts a Bundle trait as parameter, but why is that we need to supply an object that implements Component trait instead of Bundle ?
If you look at Bundle in the docs you'll see it is implemented for components and tuples of components (and tuples of bundles). Bevy puts a lot of work into things like this to make them ergonomic and intuitive. Most of the tuples implementations are done with macros under the hood
i defined a system called pig_movement for the homework . Each iteration a random direction will be picked to determine the movement of a pig. Could that be a good approach? Function looks like this: fn pig_movement( mut pigs: Query, time: Res, ) { let right = Vec2::new(1.0,0.0); let left = Vec2::new(-1.0,0.0); let down = Vec2::new(0.0, 1.0); let up = Vec2::new(0.0, -1.0); let direction = [right, left, down, up]; for (mut transform, pig) in &mut pigs { let random_index = rand::thread_rng().gen_range(0..=direction.len()-1); transform.translation.x += direction[random_index].x * pig.speed * time.delta_seconds(); transform.translation.y += direction[random_index].y * pig.speed * time.delta_seconds(); } }
That definitely looks like a good approach! If you want smoother movement you can also use timers to only select a new direction every few seconds or something
For fun sake I tried to decompose everything as much as possible. I thought despawning happens at the very end of the frame(I think unity does so), it also happened between PreUpdate and Update.
Watching this series, I'm not sold on ECS. To me, it just seems unnecessarily convoluted. One idea for a future video would be to provide examples where ECS actually provides real value compared to a non-ECS game engine. Also, in the code in this video, did you reload the pig image file every single time you press space?
It's not any more convoluted than Object Oriented game design, it's just a different approach that I enjoy a bit more than the old way. For the pig image, bevy asset system caches what images are loaded. It might be dropping the image if there are no pigs on screen so I usually would hold a handle just to ensure it never gets dropped but most the time there is no problems there in practical games.
What do you mean? The engine has docs for just about everything now. Go to the docs page and the only things that are sometimes lacking is deep rendering pieces. Also for engine code internally the git blame usually links to the PR with detailed explanations of why a feature exists
@@logicprojects for example, SystemSet. no documentation for trait methods, no documentation for derive attribute, and also no documentation for SystemSet schedule logic.
nice explanations, although the "game" is pretty boring😂 I hope this series will be useful. P.S. video quality is still problematic, I'm shocked by the fact we have to deal with such problems in 2023😢
It's a start! Bevy doesn't have the same built in niceties that unity has so it takes a bit to get something impressive. Also I thought the video quality was fixed by uploading in 4k... It looks better when I watch it back now
@@logicprojectswell, for 1080p the quality is very similar to the previous, same square artifacts. For 4k they are present too, but now they are 2 times smaller.
It was just a couple lines of code, but making my pixel pigs run on the screen made me happy! Thanks for the tutorial!
As someone who just got interested in Rust and game development, this was the perfect starter resource. Thank you!
Already looking forward to part 3!
Really pleasant to watch the video, the code snippets are really nice presented.
Thank you for all the time you invest to make them look polished
Awesome, more .11 Bevy! I hope the new job is treating you well (think I remember you saying you were switching a while ago). If onboarding is going well, and you have a good team, then that means more Bevy content for us :) .
I start the new job very soon and I couldn't be more excited :) Thank you!
very nice tutorial so far, very easy to follow.
Yes
yes
Yay part 2! Good job.
I really like your Series about bevy it is really helpful for me as a beginner.
Nicely explained
I am excited for the next one
Awesome tutorials, thanks for the great resource to get into rust/bevy, there's not much out there!
Every video I get a little more comfortable reading Query etc.
I hope eventually it will all just click for me and I can work with Bevy queries with the same confidence I write MonoBehaviour code in Unity.
Thanks! Amazing Tutorial!
Great work
Very awesome, great tutorial.
amazing
What is the practical difference at 4:00 between using a filter and a tuple of components? So for example, what is the difference between Query for the pigs versus Query for the player? To me both seem to return a set of component tuples (ie entities) that only have both of the specified components.
The With version doesn't give read access to Pig. So we're not reading pigs value, just ensuring the entity has a pig component. Practically this means another system can be mutating pig components while this runs but it's also good for expressing that this system doesn't depend on the value of pig. It's a good practice to get the minimum of mutable/read only/with that you need
@@logicprojects oh that makes a lot of sense! And I can see how this can come in very useful! Thanks for the quick answer!
Since using commands to spawn stuff doesn't actually happen when its called but rather sometime at the very end of each tick I personally like to emit events, e.g. as it's a very common and often generic thing. A Spawn event with a position and texture attribute is a generic way to handle this case for example
Great tutorial!
i need more!
Thank you!
Please make more videos!
I thought that I have understood the concept of ECS in bevy. So far, the my understanding is:
[Entity]
a unique identifier that may or may not attached to a Component or multiple Components. It does not contain any data, it is like an index or identifier to a Component or a bunch of Components shall I say.
[Component]
the data structure defined by developer to be used in the game. This data structure is meant to be registered in the StartUp schedule, which then later can be queried in the Update schedule. Suppose, two instances of the same type i.e (a struct) are meant to be queried in the Update schedule, we must create two different Components instead of one. If only one Component is defined i.e derive from Component class or interface (idk), the instances of that Component cannot be queried in the Update schedule. So, in ECS, multiple instances of a Component are absolutely obsolete.
[System]
a function that is defined with a set of parameters defined by bevy ecosystem that we want to use in a particular function/system. For example, we might need instance of `Command` structure.
So, we declare it in the parameter.
With the help of AI, it says i have 235 entities. what are the ways to reduce the entity number. I wanted to create a 4 player chess game
For components you can create new entities with your components during update as well. Components are attached to entities so you can have many copys of each component but only one for each entity. Resources are what's constrained to 1 globally.
For your chess game that's a totally reasonable number of entities. Bevy can handle much more than that without any problem
the `commands.spawn()` method in the docs it says, it accepts a Bundle trait as parameter,
but why is that we need to supply an object that implements Component trait instead of Bundle ?
If you look at Bundle in the docs you'll see it is implemented for components and tuples of components (and tuples of bundles). Bevy puts a lot of work into things like this to make them ergonomic and intuitive. Most of the tuples implementations are done with macros under the hood
i defined a system called pig_movement for the homework . Each iteration a random direction will be picked to determine the movement of a pig. Could that be a good approach? Function looks like this:
fn pig_movement(
mut pigs: Query,
time: Res,
) {
let right = Vec2::new(1.0,0.0);
let left = Vec2::new(-1.0,0.0);
let down = Vec2::new(0.0, 1.0);
let up = Vec2::new(0.0, -1.0);
let direction = [right, left, down, up];
for (mut transform, pig) in &mut pigs {
let random_index = rand::thread_rng().gen_range(0..=direction.len()-1);
transform.translation.x += direction[random_index].x * pig.speed * time.delta_seconds();
transform.translation.y += direction[random_index].y * pig.speed * time.delta_seconds();
}
}
That definitely looks like a good approach! If you want smoother movement you can also use timers to only select a new direction every few seconds or something
For fun sake I tried to decompose everything as much as possible.
I thought despawning happens at the very end of the frame(I think unity does so), it also happened between PreUpdate and Update.
It actually happens whenever the apply_system_buffers system runs which is periodically throughout the frame (including the times you spotted)
Angelita Divide
Watching this series, I'm not sold on ECS. To me, it just seems unnecessarily convoluted. One idea for a future video would be to provide examples where ECS actually provides real value compared to a non-ECS game engine.
Also, in the code in this video, did you reload the pig image file every single time you press space?
It's not any more convoluted than Object Oriented game design, it's just a different approach that I enjoy a bit more than the old way. For the pig image, bevy asset system caches what images are loaded. It might be dropping the image if there are no pigs on screen so I usually would hold a handle just to ensure it never gets dropped but most the time there is no problems there in practical games.
new bevy engine is extremely lack of documents and comments in engine code. 😖
What do you mean? The engine has docs for just about everything now. Go to the docs page and the only things that are sometimes lacking is deep rendering pieces. Also for engine code internally the git blame usually links to the PR with detailed explanations of why a feature exists
@@logicprojects for example, SystemSet. no documentation for trait methods, no documentation for derive attribute, and also no documentation for SystemSet schedule logic.
bruh the money is decreasing but the player can still spawn pigs
nice explanations, although the "game" is pretty boring😂
I hope this series will be useful.
P.S. video quality is still problematic, I'm shocked by the fact we have to deal with such problems in 2023😢
It's a start! Bevy doesn't have the same built in niceties that unity has so it takes a bit to get something impressive. Also I thought the video quality was fixed by uploading in 4k... It looks better when I watch it back now
@@logicprojectswell, for 1080p the quality is very similar to the previous, same square artifacts. For 4k they are present too, but now they are 2 times smaller.
@@logicprojects Video looked good to me :) . 1080p and 4k.