I am working on a game with a 3rd person character that can shoot, get in cover, glide, swim and … . I thought handling all these logic in actor blueprint is pretty messy. For example pressing “Right” should move character when in cover and when standing differently. So I have to use too many IFs to determine the right functionality for each input.
I was working with player controllers and realized it is best to handle input logic in player controller. So I thought maybe using multiple player controllers for each character state and switching in runtime solves the problem.
I’m still not sure what is the best practice to separate code of each state and handle input and actor logic. Please help if you know about it.
I would suggest you either consider making an Enum for different states for the movement of the character (ALS does that for example) and switch on enum at the time the player gives input.
OR (what I would do/prefer)
take a look at the Gameplay Ability System and make the various movement abilities (glide, swim, etc.) single Gameplay Abilities. That way you can handle all the logic separately. (I think Epic does it in most example projects for the character jump)
Thank you for your response.
I can manage my state and the ability I need to start with gameplay tags. But how should I manage my input? For example gliding and walking are both abilities which read realtime input to react. How should I feed my input to the ability?
I am thinking about storing input in the actor’s variables but it doesn’t seem “clean”! Because when an AI possesses the character there are no input to put in variables.