Animation state machine is obvious, but what about the game logic behind it?

If I search for “UE4 state machine” I get buried in information about the animation state machine, but basically nothing about the game logic side driving it. I’ve watched the official tutorial video on the animation state machine, but the example they use (basically building the PawnAnimationBlueprint) is TOO simplistic.

I’m making a hockey game, so I was thinking of using a state machine to govern when you are allowed to do different actions. It wouldn’t make sense to be able to body check and poke check at the same time, for example. Setting up the animation state machine to handle the animations seems pretty obvious, but as far as I can tell, there’s no way to use one state machine to handle both animation and game logic. It looks like they want you to make a duplicate state machine and then try to keep them in sync. Is there something I’m missing here?

I also had the same question and figured out that I needed two different and separate finite state machines (FSM): one for the animations and the other one for the game logic. At least this was my conclusion.

In my game, I have a FSM to handle all the game logic and check if the character is allowed to perform certain actions, according to his sate: grounded, on air, hanged, climbing, on a ledge, etc. And the Animation state machine for triggering the correct animations.

I decided to work with two FSMs because they have specific purposes. For instance, the FSM that handles your game logic can check if the player is allowed or not jump. On the other hand, the animation state machine will play the correct jump animation, according to the character’s foot that was currently on the ground (e.g.: “jumpStartLeftFoot” or “jumpSartRightFoot” animations).

For the game logic, the current animation playing its completely irrelevant. It just needs to know that the character jumped and not that it is on “mid air” state.

Yeah, that’s what I thought the answer was going to end up being. It just feels like a lot of duplicated effort. There are also some things that would be really nice about them sharing, like it would be a lot easier to wait for an animation to finish before switching game logic states. I think it’s still possible, but I might have to add AnimNotifies to my animations or poll the current animation or something, which is a pain.

You can also try creating a class that inherits from the AnimInstance class (this is the base for the AnimationBlueprint) and include there the code for your game logic as well.

I decided not do so because in my game because in our team there is a programmer for all the AI and Game logic (me) and an animator for creating all the animations. By having two different and separate FSMs, I can focus on the gameplay logic and the animator can add intermediate states for animation transitions or all the things he wants without messing with game logic. Besides, since our animator does not know programming at all, he will be working visually on the animation blueprint. On the other hand, I will be working with C++ in some specific classes I created for the FSM Game Logic.

Btw: my Skype name is Xptohz3_turbo you can contact me if you want to discuss more information or technical details about the FSMs implementation.