Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analog input range modification #505

Closed
MickHarrigan opened this issue Apr 3, 2024 · 3 comments
Closed

Analog input range modification #505

MickHarrigan opened this issue Apr 3, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@MickHarrigan
Copy link

What problem does this solve?

This allows a mapping of a certain range of analog inputs to different actions, such as walking or running on the same input.

What solution would you like?

An example of the intended usage is akin to this:

enum Actions {
    Walk,
    Run,
}

// with expected usage similar to this
let input_map = InputMap::new([
    (Actions::Walk, DualAxis::left_stick().with_range(0.0, 0.5)),
    (Actions::Run, DualAxis::left_stick().with_range(0.5, 1.0)),
]);

where bounds could be set on some analog input such that different actions are tied to either the x, y, or magnitude component of an analog input.

In setting this up you could have a 3d game in which the walking or sneaking or other similar movements tied to the distance from center for a joystick, or in a 2d sense have a method of understanding a slight tilt for look up and full tilt being a jump.
There definitely is a lot of wiggle room on this concept, and it may not even be best practice to do these things in this way.

[Optional] How could this be implemented?

My (very minimal) thoughts would be to put this with the definition of the axislike::SingleAxis as it would affect both the
single and double variants.

[Optional] What alternatives have you considered?

I am honestly not sure if this functionality exists already or if there is a clean way to do this, but from my reading of the docs I was unable to find something that seemed to do this and haven't been able to find any specific outside tooling that does this.
I would love to be proven incorrect though!

Related work

In #322 a similar concept was brought up but focused on the sensitivity of the input values rather than parsing the values from some input device.

@MickHarrigan MickHarrigan added the enhancement New feature or request label Apr 3, 2024
@Shute052
Copy link
Collaborator

Shute052 commented Apr 4, 2024

When I was thinking about #491, I considered that option, but it doesn't quite fit the bill as a processor. Maybe we could create something called "Only" or a similar processor.

But I feel like it should be implemented in #483 because returning Option or Result in the internal implementation would be better than returning 0.0 or Vec2::ZERO. Otherwise, we won't be able to easily determine which Action was actual triggered.

@vladinator1000
Copy link

vladinator1000 commented Jul 17, 2024

Just my opinion, but this feels like a niche use-case that belongs in user land. For example if you would do locomotion, you'd have the motion vector come from the right and forward axes of the input, then use it in your animation logic to play different animations based on the value. What can we gain from having a separate input action?

@alice-i-cecile
Copy link
Contributor

Yeah, I think this is best handled in user land.

@alice-i-cecile alice-i-cecile closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants