About

A straightforward but robust input-action manager for Bevy.

Inputs from various input sources (keyboard, mouse and gamepad) are collected into a common ActionState on your player entity, which can be conveniently used in your game logic.

The mapping between inputs and actions is many-to-many, and easily configured and extended with the InputMap components on each player entity. A single action can be triggered by multiple inputs (or set directly by UI elements or gameplay logic), and a single input can result in multiple actions being triggered, which can be handled contextually.

Features

Limitations

Instructions

Development occurs on the dev branch, which is merged into main on each release. This ensures the examples are in-sync with the latest release.

Getting started

  1. Add leafwing-input-manager to your Cargo.toml.
  2. Create an enum of the logical actions you want to represent, and derive the Actionlike trait for it.
  3. Add the InputManagerPlugin to your App.
  4. Add the InputManagerBundle to your player entity (or entities!).
  5. Configure a mapping between your inputs and your actions by modifying the InputMap component on your player entity.
  6. Read the ActionState component on your player entity to check the collected input state!

Running your game

Use cargo run. This repo is set up to always build with full optimizations, so there's no need for a --release flag in most cases. Dynamic linking is enabled to ensure build times stay snappy.

To run an example, use cargo run --example_name, where example_name is the file name of the example without the .rs extension.