- Home /
Good Player Input/Controller Design
Hi everyone,
Just wondering if someone can point me in the right direction or educate me on what exactly would be a good player input controller.
My question is something like, if I were making an RTS with a lot of potential keyboard commands, how do I set up the input controller? Do I have my Update function track each potential command and fire an event if so? For example :
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (Left_MouseButton_Press != null)
Left_MouseButton_Press();
}
if (Input.GetMouseButton(0))
{
if (Left_MouseButton_Pressed != null)
Left_MouseButton_Pressed();
}
// etc.
It just seems after some point, that's a lot to track during a single frame. Would I have to separate such a design by command behavior? As in, have multiple scripts with that above design but only tracking a few events each.
Thanks for any and all help and time, stay safe everyone.
Answer by logicandchaos · Jul 07, 2020 at 01:32 PM
Yes, you have to check everything, but it should be done in its own method and then called from update. Also I like to use a series of bools on the character for if a button is pressed, then the input function just triggers that bool, that way you can switch from keyboard to anything else without much hassle.