`bevy_input_focus`: Support multiplayer directional navigation
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
Co-op games want to show cursors or selected areas for multiple players at once. Currently, directional navigation controls the `InputFocus` resource, so it is only useable in singleplayer contexts.
## What solution would you like?
1. Move the `DirectionalNavigationMap` resource into a `NavigatorAgent` component.
2. Introduce an optional bitmask component that can be added to the agent and focusable areas. Masked agents can only navigate to focusable areas that belong to the mask.
A derive similar to Avian’s `PhysicsLayer` could be used on an enum whose variants occupy the lower bit ranges, leaving the remaining bits available for dynamically assigned player "layers". Observers, systems, and UI templates could remain generic by inserting the player’s index into the mask so each agent only navigates focusable areas belonging to that player.
## What alternative(s) have you considered?
- Multiple `InputFocus` resources: this would require something like `InputFocus`, `InputFocus>` with const generics or a newtype-per-player pattern which does not scale with dynamic player counts.
- A separate multiplayer cursor/focus system alongside `InputFocus`: cumbersome
## Additional context
- Avian's [`LayerMask`](https://github.com/avianphysics/avian/blob/v0.5.0/src/collision/collider/layers.rs#L86) uses masking similarly for collision layers.
### Two cursors allowed to navigate the same focusable areas:
> Each slot can only be targeted by one cursor at a time.
### 4 cursors restricted to their own focusable areas (the toolbar):
Contributor guide
Research direction
Start by reading the bevy_input_focus implementation around DirectionalNavigationMap and InputFocus, then compare the linked Avian LayerMask design. Trace how NavigatorAgent and focusable areas would participate in directional navigation; done means multiple cursors can navigate concurrently, including shared areas and optional player-specific masks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100