diff --git a/src/input_context/input_action.rs b/src/input_context/input_action.rs index 620b5e3..0d053d2 100644 --- a/src/input_context/input_action.rs +++ b/src/input_context/input_action.rs @@ -406,22 +406,22 @@ pub trait InputAction: Debug + Send + Sync + 'static { const CONSUME_INPUT: bool = true; /// Associated accumulation behavior. - const ACCUMULATION: Accumulation = Accumulation::MaxAbs; + const ACCUMULATION: Accumulation = Accumulation::Cumulative; } /// Defines how [`ActionValue`] is calculated when multiple inputs are evaluated with the same [`ActionState`]. #[derive(Default, Clone, Copy, Debug)] pub enum Accumulation { - /// Take the value from the mapping with the highest absolute value. - /// - /// For example, given values of 0.5 and -1.5, the input action's value would be -1.5. - #[default] - MaxAbs, - /// Cumulatively add the key values for each mapping. /// /// For example, given values of 0.5 and -0.3, the input action's value would be 0.2. /// /// Usually used for things like WASD movement, when you want pressing W and S to cancel each other out. + #[default] Cumulative, + + /// Take the value from the mapping with the highest absolute value. + /// + /// For example, given values of 0.5 and -1.5, the input action's value would be -1.5. + MaxAbs, } diff --git a/tests/conditions_and_modifiers.rs b/tests/conditions_and_modifiers.rs index cd9794c..7eae6e5 100644 --- a/tests/conditions_and_modifiers.rs +++ b/tests/conditions_and_modifiers.rs @@ -52,7 +52,7 @@ fn input_level() { let recorded = app.world().resource::(); let events = recorded.get::(entity).unwrap(); let event = events.last().unwrap(); - assert_eq!(event.value, (Vec2::Y * 2.0).into()); + assert_eq!(event.value, Vec2::Y.into()); app.world_mut() .resource_mut::>() @@ -117,7 +117,7 @@ fn action_level() { let recorded = app.world().resource::(); let events = recorded.get::(entity).unwrap(); let event = events.last().unwrap(); - assert_eq!(event.value, (Vec2::NEG_Y * 2.0).into()); + assert_eq!(event.value, (Vec2::NEG_Y * 4.0).into()); app.world_mut() .resource_mut::>() @@ -182,7 +182,7 @@ fn both_levels() { let recorded = app.world().resource::(); let events = recorded.get::(entity).unwrap(); let event = events.last().unwrap(); - assert_eq!(event.value, (Vec2::Y * 2.0).into()); + assert_eq!(event.value, Vec2::Y.into()); app.world_mut() .resource_mut::>()