ButtonInput not working for some combinations
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
```
bevy = { version = "0.15", features = ["dynamic_linking"] }
bevy_panorbit_camera = "0.23.0"
bevy_rapier3d = "0.29.0"
```
## \[Optional\] Relevant system information
Ubuntu 24.04.2 LTS
```
cargo 1.85.0 (d73d2caf9 2024-12-31)
```
## What you did
I got a player controller, but when I try to jump while pressing `ArrowUp` + `ArrowLeft` + `Space` it does not jump. However it does work when I press any other combination (e.g. `ArrowUp` + `ArrowRight` + `Space`). The weird part is that it does the same on the second player with `KeyW` + `KeyA` + `KeyQ`. It does look into a bug on my side but if I map the jump to `KeyP` for instance, it works well.
```rust
impl Team {
fn get_key_map(&self) -> KeyMap {
match self {
Self::Blue => KeyMap {
jump: KeyCode::Space,
left: KeyCode::ArrowLeft,
right: KeyCode::ArrowRight,
up: KeyCode::ArrowUp,
down: KeyCode::ArrowDown,
},
Self::Red => KeyMap {
jump: KeyCode::KeyQ,
left: KeyCode::KeyA,
right: KeyCode::KeyD,
up: KeyCode::KeyW,
down: KeyCode::KeyS,
},
}
}
}
fn inputs_system(
keys: Res>,
mut players: Query<(&mut Player, &KinematicCharacterControllerOutput)>,
) {
const SPEED: f32 = 3.0;
for (mut player, output) in players.iter_mut() {
player.direction = Vec2::ZERO;
let key_map = player.team.get_key_map();
if keys.just_pressed(key_map.jump) && output.grounded {
player.vertical_velocity = 0.5 * GRAVITY;
}
player.direction = Vec2::ZERO;
if keys.pressed(key_map.left) {
player.direction.x = -SPEED;
}
if keys.pressed(key_map.right) {
player.direction.x = SPEED;
}
if keys.pressed(key_map.up) {
player.direction.y = -SPEED;
}
if keys.pressed(key_map.down) {
player.direction.y = SPEED;
}
}
}
```
`pressed` instead of `just_pressed` does the same thing.
I'm just starting bevy, like from yesterday. I could have missed something.
Thanks everyone
Contributor guide
Research direction
The only entry point named is inputs_system in the report; first reproduce the listed key combinations with a minimal Bevy 0.15 example and compare ButtonInput behavior for pressed and just_pressed. Done means determining whether the failure is reproducible in Bevy itself or is specific to the reported application or environment, with a concise reproduction or explanation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100