-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Overrides for no-path in autonavigation for bevy_input_focus
#22634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Overrides for no-path in autonavigation for bevy_input_focus
#22634
Conversation
Changes navigation to use a 3-state enum, distinguishing between "unset" neighbors, "explicitly removed" neighbors, and "known" neighbors. Unset neighbors can be overwritten by auto nav building, while explicitly removed slots cannot.
Documents surprising behavior when inputting a diagonal direction (ie. `NorthWest`) when one of the components are blocked (ie. `North`)
| pub enum NavNeighbor { | ||
| /// No neighbor explicitly set. | ||
| #[default] | ||
| Unset, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this mean that it will be left to be determined automatically, so maybe Auto would be clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to Auto in latest commit.
| /// Do not find a neighbor. | ||
| Blocked, | ||
| /// The neighbor is known and set. | ||
| Neighbor(Entity), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NavNeighbor::Neighbor seems a bit redundant, maybe NavNeighbor::Set(Entity)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to Set in latest commit.
| .set(direction, b); | ||
| } | ||
|
|
||
| /// Adds an edge blocking automatic naviation from an entity in a direction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Adds an edge blocking automatic naviation from an entity in a direction. | |
| /// Adds an edge blocking automatic navigation from an entity in a direction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that, fixed typo in latest commit.
Objective
bevy_input_focus: Ability to manually set “no navigation in a given direction” for an entity #22378 .Solution
Turn
NavNeighborsfrom storing an array ofOption<Entity>to an array ofNavNeighbor, an enum with 3 values:Unset(no explicitly set thing in this direction),Blocked(assume there is nothing in this direction to path to), andNeighbor(Entity).Testing
Changes tested using a new test,
test_respects_set_blocks, and manually using thedirectional_navigation_overrideexample. Each button on second page is restricted to left/right movement, as up/down are blocked.Showcase
I'm not quite sure how to showcase this, as it's a very input-oriented feature and the feature working means that nothing happens.