Hello, Unreal friends.
I am making a little personal project, and for the main character I’m using a Finite State Machine pattern, written in C++.
The goal of using this pattern is limiting player actions when character is in determined states (such as preventing jumping while attacking, etc), whitout making it a tangle of “ifs” and “elses”.
However, I soon enter the problem of how to handle inputs whith this pattern. In a previous thread, I asked if the best way of limiting actions inside a state was to unbind all input when entering a new state, and just bind whatever the player is allowed to do.
However, I just found the GetAxisVector and GetKeyDown functions, which allowed me to do a Query in the Tick function of each state, instead of binding and unbinding controls on every change (which is prone to human error, like forgetting to unbind something).
Moreover, trying to bind actions outside of the SetupInputComponent on Character gives a compiler error, so trying to bind input on runtime is still not clear to me.
However, I don’t like using GetKeyDown, as it hardcodes the controls instead of using the input menu (which makes implementing a gamepad a pain). GetAxisVector works nice, but I couldn’t find a “GetInputAction” function that works like “GetKey”
So, my question: How can I properly (and hopefully elegantly) implement a input query for Actions on tick, instead of binding it on start or using the less elegant GetKey?