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

Поділитися
Вставка
  • Опубліковано 4 лют 2025

КОМЕНТАРІ • 44

  • @radekn.835
    @radekn.835 8 місяців тому +4

    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__ Рік тому +5

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

  • @RogersNucleus
    @RogersNucleus Рік тому +8

    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

  • @tenthlegionstudios1343
    @tenthlegionstudios1343 Рік тому +6

    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  Рік тому +1

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

  • @schmoris
    @schmoris 5 місяців тому

    very nice tutorial so far, very easy to follow.

  • @DejaimeNeto
    @DejaimeNeto Рік тому +5

    Yes

  • @jacques-dev
    @jacques-dev Рік тому +5

    Yay part 2! Good job.

  • @TimoCak
    @TimoCak Рік тому

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

  • @doce3609
    @doce3609 Рік тому +2

    Nicely explained
    I am excited for the next one

  • @MoonrayMurray
    @MoonrayMurray Рік тому

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

  • @mikkelens
    @mikkelens Рік тому +5

    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.

  • @chris73965
    @chris73965 Рік тому +1

    Thanks! Amazing Tutorial!

  • @techbytefrontier
    @techbytefrontier Рік тому +3

    Great work

  • @danesmith624
    @danesmith624 Рік тому

    Very awesome, great tutorial.

  • @njzz1801
    @njzz1801 Рік тому +1

    amazing

  • @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  Рік тому +2

      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 Рік тому +1

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

  • @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

  • @andres3665
    @andres3665 Рік тому

    Great tutorial!

  • @oabragh
    @oabragh Рік тому

    i need more!

  • @diadetediotedio6918
    @diadetediotedio6918 Рік тому

    Thank you!

  • @MatheoxMattheox
    @MatheoxMattheox Рік тому +1

    Please make more videos!

  • @footballCartoon91
    @footballCartoon91 Рік тому

    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  Рік тому

      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

  • @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  Рік тому +1

      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

  • @TimoCak
    @TimoCak Рік тому

    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  Рік тому +1

      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

  • @AM-yk5yd
    @AM-yk5yd Рік тому

    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  Рік тому +1

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

  • @CurmeBblythe-g5p
    @CurmeBblythe-g5p 4 місяці тому

    Angelita Divide

  • @Mekuso8
    @Mekuso8 Рік тому

    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  Рік тому +1

      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 Рік тому +1

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

    • @logicprojects
      @logicprojects  Рік тому +1

      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
    @comradechonky6328 Рік тому

    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  Рік тому +2

      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 Рік тому +1

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