Skip Navigation

🎮 Bevy Enhanced Input 0.15.0 is out!

Release Bevy Enhanced Input 0.15.0 · projectharmonia/bevy_enhanced_input

This update features a big rewrite into a component-based API. The core concepts remain the same, but are now expressed through ECS. It's recommended to revisit the quick start guide. Changed Inpu......

An input manager for Bevy, inspired by Unreal Engine's Enhanced Input. We use it for Project Harmonia, but it's general-purpose.

This update features a big rewrite into a component-based API. The core concepts remain the same, but are now expressed through ECS. It's recommended to revisit the quick start guide.

Showcase:

 rust
    
// Spawn a camera with an input context.
commands.spawn((
    Camera3d::default(),
    Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
    FlyCam,
    // Similar to `related!`, but you only specify the context type.
    // Actions are related to specific context since a single entity can have multiple contexts.
    actions!(FlyCam[
        (
            Action::<Move>::new(),
            // Conditions and modifiers as components.
            DeadZone::default(), // Apply non-uniform normalization that works for both digital and analog inputs, otherwise diagonal movement will be faster.
            SmoothNudge::default(), // Make movement smooth and independent of the framerate. To only make it framerate-independent, use `DeltaScale`.
            Scale::splat(0.3), // Additionally multiply by a constant to achieve the desired speed.
            // Bindings are entities related to actions.
            // An action can have multiple bindings and will respond to any of them.
            Bindings::spawn((
                // Bindings like WASD or sticks are very common,
                // so we provide built-in `SpawnableList`s to assign all keys/axes at once.
                Cardinal::wasd_keys(),
                Axial::left_stick()
            )),
        ),
        (
            Action::<Rotate>::new(),
            Bindings::spawn((
                // You can attach modifiers to individual bindings as well.
                Spawn((Binding::mouse_motion(), Scale::splat(0.1), Negate::all())),
                Axial::right_stick().with((Scale::splat(2.0), Negate::x())),
            )),
        ),
        // For bindings we also have a macro similar to `children!`.
        (Action::<CaptureCursor>::new(), bindings![MouseButton::Left]),
        (Action::<ReleaseCursor>::new(), bindings![KeyCode::Escape]),
    ]),
));

  

Advantages of the new API:

  • You can use Bevy scenes to describe bindings. When BSN lands, we'll get hot-reloadable actions for free. In UE, this is also expressed via Blueprints.
  • Everything is inspectable.
  • Modifiers and conditions are now accessible in systems, allowing you to adjust or read their data if needed.
  • Actions can be queried - especially convenient when using Single.
  • Things that didn't benefit from being static, such as prioritization and action settings, are now dynamic.
  • Things that were "inspired by Bevy," such as how bindings were defined, modifiers and presets, now actually utilize the Bevy API - meaning new users don't have to learn additional concepts.
  • The crate logic is much simpler.

Huge thanks to Alice for reviewing this monstrous +6,127 −5,738 PR!

📜Full changelog 📦bevy_enhanced_input

Comments

0