Git Product home page Git Product logo

Comments (4)

cart avatar cart commented on August 17, 2024 1

Yeah I knew this going into it. I wanted to illustrate the pattern of breaking up a "traditional" data structure into its core pieces (in this case the Person marker component and the Name component). I think including another system with (&Dog, &Name) would help illustrate the reuse and the value of the marker components. In this case, including "Person" in the query ensures we only run on entities with (Person, Name) instead of any entity with Name.

However in practice to suppress the "unused variable" warning and reduce the amount of data accessed, we would actually write the query like this:

Query<With<Person, &Name>>

That runs on the same dataset, but only iterates over the Name components. I didnt use that approach because I didnt want to over-complicate the query with With that early in the book.

I can definitely see how this is confusing. If you have suggestions let me know.

from bevy-website.

dgb23 avatar dgb23 commented on August 17, 2024 1

If you have suggestions let me know.

I think you answered it yourself!

In this case, including "Person" in the query ensures we only run on entities with (Person, Name) instead of any entity with Name.

Maybe there is an opportunity here to show this in the tutorial. I personally have a "break things to learn things"-approach and find it very powerful and I feel like the tutorial is written with this mindset too.

So maybe introduce this "bug" by declaring an entity with a name component which we don't want to greet!

EDIT:

I just tested it by introducing a Dog entity and then querying just the name mut query: Query<&Name> and like so mut query: Query<(&Person, &Name)> and it does exactly what is expected. I think this little addition would be helpful to understand the quasi relational aspect of your system.

from bevy-website.

visualcode-t avatar visualcode-t commented on August 17, 2024

I don't think there is a real issue here. It seems pretty clear in the book, to me. But, if clarification is needed, I do see two ways to clarify this. First, is to add the Dog entity, as already mentioned. The second would be a little more specific:

The parameters we pass in to a "system function" define what entities the system runs on. In this case, greet_people will run on all entities with the Person and Name component.

Could be...

The parameters we pass in to a "system function" define what entities the system runs on. In this case, greet_people will run on all entities that have both the Person and Name component.

And for queries:

Now our App should properly greet all People, once every two seconds!

Could be...

Now our App should properly greet all Persons that have a name component, once every two seconds!

from bevy-website.

alice-i-cecile avatar alice-i-cecile commented on August 17, 2024

Closing out; this is no longer how our syntax works :)

from bevy-website.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.