rustrogueliketutorial
rustrogueliketutorial copied to clipboard
2.5 Misleading text
Near the end of the chapter the following is written:
We also need to give the player a name; we've explicitly included names in the AI's join, so we better be sure that the player has one! Otherwise, the AI will ignore the player altogether. In
main.rs
, we'll include one in thePlayer
creation:
While it's perfectly fine and reasonable to give the player a name, the AI will not ignore the player without one, as the player position is obtained outside the for loop from the system's SystemData
. In fact the player continues to be left out of the for loop even after adding a Name
because the iterator is also joined on the tag Monster
I noticed this as well. This line could lead some readers to be confused about how ECS lookups actually work if they aren't already familiar. Really, that section of code isn't even touching the player entity at all. The closest thing it does is read the player position resource.