You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So what you're running into is when you request a &mut Position in your system, Bevy hands you Mut<Position> instead.
Mut is a "smart pointer" used to implement change detection. When it's mutably dereferenced, Bevy says "hey, this value was probably changed!". The downside of this is that the ergonomics are sometimes surprising.
Mut implements Deref and DerefMut, so fields and methods are "forwarded" to the internal type. That's why setting the field values works. But to assign to the internal value (and not the smart pointer), you need to dereference it first. Same with doing things like adding or subtracting the values with straightforward trait impls
We should probably talk about matching as well.
I'm not sure what section of the book this belongs in, maybe a "frequently encountered problems" section? Maybe an aside in the section on queries?
The text was updated successfully, but these errors were encountered: