Skip to content

State Switch

Using the old Input System, it was very common to perform if/else statements as a reaction to certain key presses, to determine if certain states should be activated or deactivated, based on any arbitrary state criteria.

A classic example is, once again, crouching. Pressing ctrl will make the character crouch. Pressing again, if the character is crouched, will make the character un-crouch.

This style of state evaluation is not exactly aligned with the Enhanced Input's design, so this Handler is meant to be a facilitator to transition this logic from the old system. It allows toggling states in your Pawn or Character, through the InputStateSwitchInterface.

Implementing this interface in your Pawn/Character enables this style where an Input can be used to Activate or Deactivate something, based on any arbitrary logic. The interface allows you to inform, via a Gameplay Tag, which state is being toggled, so implementing this interface once, should cover any states being managed.

But who knows, right?

Of course, if you find additional usages unrelated to this transtion between systems then by all means, go ahead and use this Handler/Interface to your heart's content!