Multiple input key press actions

I had a similar requirement for a different feature. The way I solved it was to:

  • Bind Inputs in Character to know when Forward, Backward, Left and Right keys are down
  • Create a calculator that determines the current movement direction
  • Create an instance of this direction calculator on my Character
  • Notify calculator when Character Movement inputs occur
  • Whenever Character needs to know what keys are down it calls the Movement Direction calculator

It’s quite cumbersome to calculate this but I “over-formalised” it into an InputDirectionCalculator as you can see here: Bitbucket