-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
InputEvent get_action() if is_action_type() true #9408
Comments
I'm not following here, what do you mean by:
You can get this property, but what are you asking for specifically? That it would be type safe? What's wrong with the example code you gave? |
No, I mean it can also be a |
Yes you can, what are you unable to do? |
So I would have to do this, right?
|
Oh yes that's true, sorry you were not clear that you weren't talking about input actions being fired :) I assumed you meant when you actually got those Input doesn't handle actions directly, so you are supposed to use the |
Yeah, the |
You can't, because it doesn't work that way, there isn't an action, there could be many, or none |
But there is this method |
No, that just means it's an |
That sounds about right. With that in mind, why can't it be possible to access the action after that check? Or more accurate an array of actions as there can be many.. |
How? What action? How would you find an action? Would it only return if there was exactly one? How would this be checked? Also there's fuzzy actions which means you can partially match them? What would be better about this than using the method designed to do this? |
Well, I described that already above. Currently I need to go through a list of elements that are bound to an action in any case to check if there is a match on one. |
And you would have to do that if it returned an action as well, you'd need to check all those returned values, it would be very inefficient compared to just checking against them I think this is a case of you not having a setup that's efficient, why not just create an array of To me it sounds strange to have a "react on any of these actions", just have "if X, do A, if Y do B"? Fuzzy actions is the Your use case doesn't sound like a normal use case, so it isn't necessarily going to be supported by the engine |
Well, I am already doing the check with the list. But if the action would be accessible I could avoid some checks but you're kinda right, it wouldn't make a huge difference in terms of performance as there would still be checks after every input event. The best solution would be to introduce signals related to actions. |
There's a proposal for just that: |
Okay, cool. Thanks @AThousandShips for everything! |
Describe the project you are working on
Trying to build an in-game ui that includes pieces like windows and other elements that can be bound to input actions.
Describe the problem or limitation you are having in your project
The problem right now is that it is not possible to get the action name from the
InputEvent
therefore I have to go through all the ui elements with actions to check if one of them could be a match with theis_action..()
methods. The current state is very inefficient and doesn't allow to build dynamic action related ui's.Describe the feature / enhancement and how it helps to overcome the problem or limitation
If it was possible to get the
action
after the check that already existsevent.is_action_type()
, it would be possible to also structure action elements with a prefix likewindow_inventory
and if the action doesn't begin withwindow_
don't do any further checks on that matter like now.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Example:
I know that InputEventAction wasn't built for this exact purpose but maybe its not that hard to change it to this without breaking other edges.
If there is a more efficient way to make it possible to read the action I would go for that instead of the proposal.
Look at the proposal as demand for the action to be read from the
InputEvent
if it contains one.If this enhancement will not be used often, can it be worked around with a few lines of script?
It will be used often that is certain. While researching about this issue I saw that there are a lot of people on reddit or other forums asking for how to get the action name for dynamic purposes.
The workaround is ugly and inefficient as I mentioned in the problem section. You have to go through all the list(s) and match it against the
is_action...
methods during an input event.Is there a reason why this should be core and not an add-on in the asset library?
Yes, because input is core.
The text was updated successfully, but these errors were encountered: