Leafwing-Studios / leafwing-input-manager

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

How would I pass a mouse position through an input? #592

Open simbleau opened 2 months ago

simbleau commented 2 months ago

I'm switching from natively serialized inputs to leafwing, and I realized that the ActionLike macro removes the ability to push data with your inputs.

Before I had something like this:

enum Inputs {
    MovingTo(x: 32, y: 32),
    MoveUp,
    MoveDown,
    ...
    Standing(dir: f32)
}

However, since ActionLike requires Hash, it greatly limits my ability to derive ActionLike on Inputs.

Specifically, in my game, imagine it's like League of Legends where you click on the screen, and that sends a MovingTo(x, y) input.

How does one accomplish this with Leafwing?

alice-i-cecile commented 2 months ago

You should call ActionState::set_axis_pair, and store that information in the ActionState struct associated with your MovingTo variant :) This would be a good example though, so I'm going to leave this open.