Leafwing-Studios / leafwing-input-manager

A straightforward stateful input manager for the Bevy game engine.
Apache License 2.0
699 stars 108 forks source link

Reading a button as an axis value no longer works #648

Open tec27 opened 5 days ago

tec27 commented 5 days ago

Version

0.15.1, or current main ( 5bb37ff7d07e472c0095a4b8fd60cbca6a1cd155 )

Operating system & version

Windows 11

What you did

1) Run the axis_inputs example (cargo run --example axis_inputs) 2) Press right trigger 2

What you expected to happen

The program should print the value of the trigger press depth

What actually happened

The program crashes:

thread 'Compute Task Pool (18)' panicked at C:\Users\Travis\.cargo\registry\src\index.crates.io-6f17d22bba15001f\leafwing-input-manager-0.15.1\src\action_state\mod.rs:594:14:
assertion `left == right` failed
  left: Button
 right: Axis
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `car_game::car::control_player`!
Encountered a panic in system `bevy_app::main_schedule::FixedMain::run_fixed_main`!
Encountered a panic in system `bevy_time::fixed::run_fixed_main_schedule`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
error: process didn't exit successfully: `target\debug\car-game.exe` (exit code: 101)

Additional information

It looks like this assertion was added in: https://github.com/Leafwing-Studios/leafwing-input-manager/commit/5e90a7de5e438ea66704bf0eb90458528077591f

I'm not sure if the example needs to be updated to some alternative method (from looking through the docs I didn't see a great way of getting the button value at a higher level), or if this assertion isn't appropriate at this location.

alice-i-cecile commented 5 days ago

This is a bug in the example, and intended to not work. The example should be checking the axis value explicitly.