Hi
(First, Im not sure this is the right forum for this, so admin feel free to move the thread if there is a better place).
I’m not sure “context based” is the right word here, but let me explain.
I am building a FPS game in Unity (see link to my Youtube channel in my signature if interested).
In this game the player can of cause move around FPS-like with Mouse and WASD. All good.
The problem arises when some inputs should no longer have an effect or a button have a different meaning in the current context.
In my FPS sample, lets say you move around on WASD, then when pressing tab, an inventory shows on screen and here you select an item WASD too. This also means, that as long as this inventory UI is shown, the WASD input for moving the player shouldn’t be active.
And you can imagine maybe cases like this where input are handling in a “context”.
I’m a professional programmer in my day job, so I like my code and architecture to be as simple and solid as possible, so it’s easy to make changes and hard to break stuff.
The reason I’m mention this, is that I know of way I can create various hacks to accomplice this thing, it just becomes very “hacky” and hard to understand and objects becomes very dependent on each other - which I want to avoid.
Right now I have been trying to accomplice this using a messaging system, already use that in game anyway, and then disable certain components etc., but still haven’t found a good way of doing this. It be comes too complicated way too soon.
So, I’m interested in hearing/seeing how you have solved this problem in a good way.
And just to make it clear, I’m not interested in seeing how I can use CrossPlatformInput.Get(…) to get the input - that’s not the question. The architecture/structure around how to use this input is the topic