pub trait Actionlike: Eq + Hash + Send + Sync + Clone + Hash + Reflect + TypePath + FromReflect + 'static { }
Expand description

Allows a type to be used as a gameplay action in an input-agnostic fashion

Actions are modelled as “virtual buttons”, cleanly abstracting over messy, customizable inputs in a way that can be easily consumed by your game logic.

This trait should be implemented on the A type that you want to pass into InputManagerPlugin.

Generally, these types will be very small (often data-less) enums. As a result, the APIs in this crate accept actions by value, rather than reference. While Copy is not a required trait bound, users are strongly encouraged to derive Copy on these enums whenever possible to improve ergonomics.

§Example

use bevy::prelude::Reflect;
use leafwing_input_manager::Actionlike;

#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Reflect)]
enum PlayerAction {
   // Movement
   Up,
   Down,
   Left,
   Right,
   // Abilities
   Ability1,
   Ability2,
   Ability3,
   Ability4,
   Ultimate,
}

Object Safety§

This trait is not object safe.

Implementors§