Learn Bevy! Custom Components/Resources and Gameplay (part 2)

Ғылым және технология

Welcome to part 2 of my intro to Bevy series. Sorry for the delay on this part, I just moved into a new house and had no internet for a week!
Discord Invite: / discord
Patreon: / logicprojects
Github: github.com/mwbryant/logic_far...
Chapters:
0:00 Intro
0:14 Custom Component
1:31 Camera Settings
2:05 Custom Resources
3:14 Pig Spawning
3:55 Filters
4:51 Pig Spawning Impl
6:08 Pig Lifetimes/Timers
7:14 Entity Queries
8:34 Final Product
8:43 Outro

Пікірлер: 42

  • @radekn.835
    @radekn.8352 ай бұрын

    It was just a couple lines of code, but making my pixel pigs run on the screen made me happy! Thanks for the tutorial!

  • @emartinez__
    @emartinez__11 ай бұрын

    As someone who just got interested in Rust and game development, this was the perfect starter resource. Thank you!

  • @DejaimeNeto
    @DejaimeNeto Жыл бұрын

    Yes

  • @logicprojects

    @logicprojects

    Жыл бұрын

    yes

  • @RogersNucleus
    @RogersNucleus Жыл бұрын

    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

  • @jacques-dev
    @jacques-dev Жыл бұрын

    Yay part 2! Good job.

  • @tenthlegionstudios1343
    @tenthlegionstudios1343 Жыл бұрын

    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 :) .

  • @logicprojects

    @logicprojects

    Жыл бұрын

    I start the new job very soon and I couldn't be more excited :) Thank you!

  • @doce3609
    @doce3609 Жыл бұрын

    Nicely explained I am excited for the next one

  • @mikkelens
    @mikkelens Жыл бұрын

    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.

  • @techbytefrontier
    @techbytefrontier Жыл бұрын

    Great work

  • @danesmith624
    @danesmith624 Жыл бұрын

    Very awesome, great tutorial.

  • @Lumens1
    @Lumens1 Жыл бұрын

    I really like your Series about bevy it is really helpful for me as a beginner.

  • @chris73965
    @chris73965 Жыл бұрын

    Thanks! Amazing Tutorial!

  • @MoonrayMurray
    @MoonrayMurray9 ай бұрын

    Awesome tutorials, thanks for the great resource to get into rust/bevy, there's not much out there!

  • @andres3665
    @andres3665 Жыл бұрын

    Great tutorial!

  • @njzz1801
    @njzz1801 Жыл бұрын

    amazing

  • @diadetediotedio6918
    @diadetediotedio6918 Жыл бұрын

    Thank you!

  • @oabragh
    @oabragh Жыл бұрын

    i need more!

  • @kashnigahbaruda
    @kashnigahbaruda Жыл бұрын

    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

  • @MatheoxMattheox
    @MatheoxMattheox11 ай бұрын

    Please make more videos!

  • @abacaabaca8131
    @abacaabaca8131 Жыл бұрын

    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 ?

  • @logicprojects

    @logicprojects

    Жыл бұрын

    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

  • @cvbattum
    @cvbattum Жыл бұрын

    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.

  • @logicprojects

    @logicprojects

    Жыл бұрын

    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

  • @cvbattum

    @cvbattum

    Жыл бұрын

    @@logicprojects oh that makes a lot of sense! And I can see how this can come in very useful! Thanks for the quick answer!

  • @AM-yk5yd
    @AM-yk5yd11 ай бұрын

    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.

  • @logicprojects

    @logicprojects

    11 ай бұрын

    It actually happens whenever the apply_system_buffers system runs which is periodically throughout the frame (including the times you spotted)

  • @footballCartoon91
    @footballCartoon918 ай бұрын

    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

  • @logicprojects

    @logicprojects

    8 ай бұрын

    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

  • @Lumens1
    @Lumens1 Жыл бұрын

    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(); } }

  • @logicprojects

    @logicprojects

    Жыл бұрын

    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

  • @Mekuso8
    @Mekuso811 ай бұрын

    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?

  • @logicprojects

    @logicprojects

    11 ай бұрын

    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.

  • @l999358
    @l999358 Жыл бұрын

    new bevy engine is extremely lack of documents and comments in engine code. 😖

  • @logicprojects

    @logicprojects

    Жыл бұрын

    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

  • @l999358

    @l999358

    Жыл бұрын

    @@logicprojects for example, SystemSet. no documentation for trait methods, no documentation for derive attribute, and also no documentation for SystemSet schedule logic.

  • @comradechonky6328
    @comradechonky632811 ай бұрын

    bruh the money is decreasing but the player can still spawn pigs

  • @adsick_ua
    @adsick_ua Жыл бұрын

    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😢

  • @logicprojects

    @logicprojects

    Жыл бұрын

    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

  • @adsick_ua

    @adsick_ua

    Жыл бұрын

    ​@@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.

  • @tenthlegionstudios1343

    @tenthlegionstudios1343

    Жыл бұрын

    @@logicprojects Video looked good to me :) . 1080p and 4k.

Келесі