Please make a backup of your project before following this guide.

First go to the Enums folder in the blueprints folder and create a new enumeration called E_BlockType then open it and copy the image below then save.

Next open the BP_AIInterface blueprint and create a new function called AI Block, then 2 inputs the first call Block Type and set the variable type to E_BlockType. The second input call Block Attacker and set the variable type to Actor. It should look like the image below.

Next go to the animations folder then to the AnimNotifys folder and create a new blueprint class then click the All Classes drop down and search for AnimNotify select it and click select.

Call the new blueprint Notify_BlockAttack and open the blueprint. Next in the functions list hover your mouse over the + and select the override option and select to override the Received_Notify function.

Next create the 2 new variables listed below.


Variable Name — Directional Block

Variable Type — Bool

Tick Instance Editable

Tool tip – “If true the attack target can only block this attack if it is coming from in front of them”


Variable Name — Attack Type

Variable Type — E_BlockType

Tick Instance Editable

Tool tip – “This tells the attack target the attack type (You can then set the attack targets block chance to this type of attack in its Smart AI component)”


Next go to the Received_Notify function and create 2 new local variables listed below.


Local Variable Name — Mesh Comp L

Local Variable Type — Skeletal Mesh Component


Local Variable Name — Attack Target L

Local Variable Type — Actor


Now copy the images shown below.

Next go to the BP_SmartAIComponent you will need to create 6 new variables listed below.


Variable Name — Can Block

Variable Type — Bool

Tick Instance Editable

Default value — Set to true if you want you AI to be able to block

Category — Blocking

Tool Tip — “If true when the AI is attacked a check will be done to see if it can be blocked”


Variable Name — Block Chances

Variable Type — (Click Here for video example)

Tick Instance Editable

Category — Blocking

Default values — (Click Here for Image)

Tooltip — “This is the chance the AI has of blocking a attack type (100 the attack will always be blocked 0 the attack will never be blocked)”


Variable Name — Melee Block Anims

Variable Type — Array — Anim Montages

Tick Instance Editable

Category — Blocking

Tooltip — “These are the animations used when a melee attack is blocked”


Variable Name — Block Timer

Variable Type — Timer Handle


Variable Name — Block Cooldown

Variable Type — Float

Tick Instance Editable

Category — Blocking

Default Value — 2

Tool Tip — “This is the cooldown for the AI being able to block another attack”


Variable Name — Blocked Attack Montages

Variable Type — Anim Montage

Tick Instance Editable

Category — Blocking

Tooltip — “These animations are played when this AIs attack is blocked”


Once you have created all the variables listed above in the BP_SmartAIComponent go to the BP_AIMasterHoldable and create the same variables listed above there as well.

Next go back to the BP_SmartAIComponent and go to the event graph and create a new custom event called Start Block Timer add a input called Time and set its type to float.

Next create a second custom event called End Block Timer, then copy the image below.

Next right click in the event graph and search for event AI Block and create the node. Then create a new function in called Check Block then open the function.

Add 2 inputs to the function the first call Block Type and set its type to E_BlockType and the second call Block Attacker and set its type to actor.

Next copy the images below, I have split the up as this is a large function.

Next in the event graph copy the image below.

Next go to the Axe_Attack_01_Montage and add the block attack notfiy we made earlier, to add the notify scroll down to the notifies panel, right click hover over add notify and select the block attack. Like show in the image below.

Next select the block attack notify you just created and in the details panel you can set the attack type and if the attack is directional.

Next you will need to create a new Smart AI project in the launcher, once that is done search in the content browser for Block and migrate the A_SwordBlock_01 and A_SwordBlock_01_Montages to your project.

If you are following this guide while it is still (Coming Soon) download the file linked below, import it in to your project and select your skeleton for the skeleton option. Once imported right click the animation and create a montage.

https://www.dropbox.com/s/594f1cc4taolbqw/A_SwordBlock_01.FBX?dl=0

Now the block system is set up, you can now go to the Smart AI component and set the A_SwordBlock_01_Montages in the Melee Block Montages if you want to use it and you can do the same for your holdables.

NOTES – If your AI doesn’t block make sure you have enable Can Block on your weapon of Smart AI component. If you are unsure of what a setting does read the tool tip.