AI & Units - MassiveMiniteam/OddModKit GitHub Wiki
StateMachine
The UBTStateMachineComponent is our StateMachine. It provides functions to transition to states, ticks behavior trees and handles StateGroups.
StateGroups
A StateGroupMapping is a DataAsset and an abstraction around StateGroups. GameplayTags are mapped to a StateGroup asset. This enables that for example the attack state of an enemy can be different but the implementation just jumps to the StateGroup marked as AI.StateGroup.DefendSelf. The UBTStateMachineComponent holds a reference to the used StateGroupMapping and provides functions to transition to a StateGroup tagged with a certain GameplayTag.
A StateGroup chooses the actual State that will be transitioned into by going in order through a list and checking for conditions. This for example handles what a Spark does when it lands after a throw. Like attacking an enemy when there is one nearby, harvesting or picking up an item.
BehaviorTrees
We tick our own behavior trees to make them deterministic.
They still use the normal BehaviorTree but you need to use our LocSequence, LocSelector and LocWait. Decorators are supported when they inherit from BTDecoratorBlueprintBase. Tasks need to inherit from BTTaskLocBlueprintBase.
States
A State refernces the behavior tree that runs during that state and sets up the needed blackboard variables in OnStateEntered. Unless the "LoopBehavior" is true, the state exits when the behavior tree finishes.
Pathfinding
The PathFinderSimulationComponent handles starting a pathfinding request. The UnitMovementSimulationComponent uses that component and moves the actor along the calculated path.
The pathfinding is a simple A* with some conditions like jumping and moving through corrupted buildings.
The PushbackSimulationSubsystem handles that units collide with each other (if their bitmask says so) but the pathfinding does not know about it.
GridMovement
Movement on a path is different. Every GridCell has 4 subgrid positions and the USubGridMovementSimulationComponent handles movement over those positions