I have a character in my game that can be in many different states. In each different state I want the input buttons to do something different. For instance, if the character state is WEAPON_SHEATHED
then the attack button simply unsheaths the weapon. If WEAPON_READY
, the attack button attacks. I have a bunch of other states as well:
- CARRYING_OBJECT
- CLIMBING_LADDER
- HOLDING_TORCH
- SWIMMING
- etc etc
At the moment on input I am doing a dirty branch chain that just rolls through and checks the player_state enum and âinterceptsâ the button press. This is long winded and inflexible and I hate it. What I want to do is delegate my input calls to a player state class that performs the action, and swap the class out whenever the state changes.
I have built this whole projects in blueprints so far - Iâm not scared of c++ if I have to go that way but Iâd like to keep it in blueprints. Is there a way in blueprints to have dependency injected classes like this? Does it need to be a component? A Variable? A totally separate blueprint that the player class messages? Is this doable in blueprints or am I going to need to fire up visual studio?
Thanks in advance!