I can’t find a way to fix the problem that sometimes the AI moves while crouching.
Behavior tree:
In this video, you can see that the AI sometimes moves while crouching, which is not acceptable because he needs to always move with his walking animation:
In this video, you can see what the behavior tree looks like during the game:
I can’t understand why sometimes it moves correctly but sometimes it moves while crouching.
One possible solution that came to mind was to use a selector instead of sequence at the beginning, but I didn’t know how to create a condition for it to switch to the other branch.
CoverTask:
AttackTask:
The CoverTask and AttackTask are triggering the Cover and Attack interfaces or events, and these events are trying to manipulate the state machine inside the animation blueprint:
This is the state machine, and those double arrows show what is inside the transitions:
The way Return First State is being triggered is that when the animation inside NoCrouch ends, there is a notify so that I can take advantage of that, like below.
This is the noCrouch notify:
Here is how it returns to the Idle/Walk/Run:
The way the Attack state returns back to Idle/Walk/Run is that there is a notify at the end of the attack animation: