Handle character with multiple behavior state best practice

Hi.
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.

Thank you in advance

Hello :wave:
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)

Hope that helps! :+1:

Greetings,
Markus
Bagpack Games

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.

1 Like

Ah I see, so I don’t know if you are at least a little familiar with C++?

For our project I built a C++ component that is exclusively responsible for binding inputs to delegates that you can then bind and assign via Blueprint.

But as far as I remember there is also a way to assign an ability a specific input but I fear this is also C++ related.

Here are some ressources I used:
Epic Games Guided Tour of the Ability System
Epic Games Modular Game Features

Hope that helps! :grin:

Greetings,
Markus
Bagpack Games

I am actually very comfortable writing C++ code. I watched about 20 minutes of Modular Game Feature video and it was exactly what I needed. Thank you so much!!!

1 Like