Pig Pal~
About
Pigpal is a small prototype friendly AI, an animal companion character that would accompany the PC in a larger scale game.
The CodeThe images below show the behaviour tree, some of the c++ tasks created for the tree, and the animation blueprint. The full repository can be found here.
Behaviour TreePal's behaviour tree always checks for any commands from the player (set by gameplay tags) that override any other tasks. If not under command, pal stays by the player character unless an enemy comes into view, in which case pal prioritises attacking.
Attack TaskOnce an enemy has been identified, it's added to the blackboard. This task sets pal as in attack mode (used by the animation blueprint) and makes an attack against the enemy. The task returns a failure when the enemy is killed so that the attack sequence node on the behaviour tree is ended, otherwise pal will continue to attack.
Animation BlueprintIf pal isn't under specific command or attacking, the animation blueprint uses a basic blend space that includes idle, walking, running, and turning animations. A separate blend space is used for the foraging command. State machines control the animations for waiting (in which pal lies down and stands back up when called to return) and attacking.