How to modify functions based on player State (non-AI)

I’m having trouble finding a solid strategy for changing how various functions work (or if they are to be ignored) in my Blueprints based on a player’s current “state” … like as was done in an UnrealScript manner. For example, if the player is the state PlayerWalking - he has the ability to move around and shoot like normal. But, let’s say the player ends up in a PlayerSpectating state - maybe they can now fly around (in freecam) but is no longer allowed to shoot. When in PlayerDead, they can neither move nor shoot until respawned - which is what happens when you do attempt to shoot after a short timer expires. That kind of thing.

I see similar functionality in AnimGraphs - though let’s say this is for a FPS vehicle-based game with no character animations to be guided thru Persona as an example. I’m wondering if I should start looking into Behavior Trees (where much discussion seems to be around AI implementation) and try to merge this into my PlayerController? Should I instead embed the functionality in much larger functions that branch all over the place based on state information I need to hold in a variable or two [ex: Branch if PlayerState = “Dead”]? Or, have I missed some obvious feature that’s so far eluded me in the context menus? Tried to be diligent in searching around for an answer, but haven’t seen a lot of folks talking about this yet.

Appreciate any thoughts!

Hello

You can try making a PlayerState Enum and then doing a Switch on Enum to control what the player can and cannot do using Booleans? just have the server check what the player’s PlayerState is before it allows the player to make any actions. just place the Switch on Enum inside a function that will take in a player controller so that u can filter who the server should be making the checks for. and then Cast to the player to set what they can do.

I hope this helps get you in a helpful direction!

You can also have a look at the ShooterGame.
If i remember correctly, it uses PlayerStates. And yes, this is just an Enum
that gets checked.

This is the exact direction I wound up going in - but it’s good to have some confirmation from you guys that this is how you’d handle it as well. Seems to be a little more messy than necessary but it works okay. Thanks for the reply!