Hey All! I have a quick question, and I was curious what your opinions would be!
I have a WeaponComponent
that can be fired in nearly any state, say JumpState
, MoveState
, IdleState
, and SwimmingState
. BUT, it cannot be fired in only one state, ClimbingState
.
My question is, should I make it so that the PlayerCharacter
consumes the input for shooting in its own class, and does not propigate (relay) the Input Event
down to the current state, since shooting can be done in nearly any state. Then have the WeaponComponent
check for one state (if the player is in ClimbingState
or not), and if the player is not in the ClimbingState
then fire the code to shoot. This basically encapsulates all of the shooting logic within the PlayerCharacter
and the WeaponComponent
. Or since shooting a weapon cannot be shot in every single state. The PlayerCharacter
should propigate the “shoot” input down to the state machine and then down to the current state the player is in. Then if there is an if-statement
in that current state, like if(InputAction->GetName() == "IA_Shoot")
, then the shooting logic will fire, if not, then nothing will happen.
Both options work, but you know best practices, and I am unsure if it would be better practice to put non-state related component logic within the PlayerCharacter
only. Or always put it in the individual states no matter what.