# What is a proper way to handle player inputs based on different states?

So, I have two ideas how to do that:

• Use enum to define current state and check current state value before running certain method group in Update. Code:

void Update()
{switch(currentState){
case 1:
InputGroup1();
break;
case 2:
InputGroup2();
break;
<...>
}


And so on. I don't think that this is a good idea because of possible performance drops.

• Same concept about current state, but instead of checking it and running method groups, "head" script will check current state and activate corresponding script, disabling others. For me it looks like best way in terms of performance and usability.

And also, is it better to keep all input checks in one giant script/component and call functions you need from it? Essentially creating centralized Input Manager.

• "possible performance drops" are not a real problem. Actual, measured performance drops are a problem. So: did you try writing and running this code? Did a single switch really turn out to be a substantial drain on your performance? If not, go do that before asking here. Both these options are valid - it's up to you what works better for the style of coding you and your team prefer for the needs of your current project. Jul 27 '19 at 3:59

Deciding where an if/switch should go when it's called only once or so per frame is irrelevant, most of the time.