I’m currently working on an RTS game and learning while doing. I’ve found multiple tutorials using the old input approach and managed to switch everything to the newer enhanced input action. Sweet. I am just a big fan of clean and elegant coding.
Now I have the following challenge:
I’m using the number keys (0…9), but AND dont want to use the old method AND want to use the new IA system, but NOT program and input action for EVERY single number. This means one Input Action (“IA_RTS_PressNumberkey”, type digital bool) and in the Input Mapping Context(IMC) I defined all number keys 0 through 9.
The old method we don’t want to use, because why program 10x when 1 routine would be better?
The number keys set in the IMC under one IA
Next step is (after setting the Add Mapping Context routine) is to program an event:
“EnhanceInputAction A_RTS_PressNumberkey” and I try to get some code working to detect which of the number keys is pressed.
Note: The “Query Keys Mapped to Action” approach in many videos online (and then looping through the array) just isn’t working properly. Secondly, this function is for cosmetisch only and not intended for gameplay actions (hover mouse over and you’ll see this).
The Query Keys Mapped to Action that isn’t working either, or at least, not intended for gameplay actions.
Apparently, even chatGPT is giving wrong information, telling me just to use the ‘Get Key’ function directly from the Action Value which in my case, is a bool and doesn’t work.
My option (eventually) is to create 10 input actions for each number, and using an event on each of them, but this is very cumbersome. A more elegant way must excist. I must be overlooking this, since it cannot be that difficult.
→ Question: Does anyone have an elegant solution for this?
Much appreciated.