Enemy AI Constructor allows you to create enemies with various behavior in minutes. It is 100% done in blueprints. There are three enemy archetypes you can use for your enemies as a base
You can customize parameters, such as: name, description, HP, MP, damage, movement speed (separate for patrol and combat mode), radius in wich enemy will detect the player, and so on.
You can set enemies to patrol the whole level or a certain area, or they can stand still and wait for the player. You can create social enemies (i.e if you attack one, the rest of the group will start to attack you as well).There is a blueprint to spawn specific or random enemies. You can define, how many and what type of enemies will spawn, and place the customized spawner on your level.
In Enemy AI Constructor you will find basic skills for your enemies. To show what you can achieve with AI constructor, we made several skills, including a magic projectile and a meteor, falling from above. Player also can use skills and do damage to the AI enemies.
Also, there is a widget, which displays enemy name, description and current health points.
To fix this, edit Max Agents parameter in Edit → Project Settings → Engine → Crowd Manager.
To fix this, enable dynamic NavMesh generation: Edit → Project Setting → Navigation Mesh → Runtime Generation → Dynamic.
To add new functionality to your project, it is necessary to establish interactions between Enemies and the Player. There are two methods:
You may need to remove extra components, such as Camera duplicate, if something appears after Reparent.
Open Constructor\Blueprints\Utility\BFL_UtilitiesLibrary and recover the following library methods:
Usually you don't need to touch those methods, but just in case here they are:
Make new blueprint as a child to the BP_Enemy blueprint.
Open it and change the ID in variables section. It must contain unique ID for each enemy. To check if the ID is used, just look it up in NPCTable.
All AI NPCs get parameters from NPCTable. After you create a new Enemy, you must create a new record about it in the NPCTable. Just press ‘Add a new row’ and put the Enemy ID in ‘Row Name’ and fill the EnemyBP and BegaviorTree cells.
There are some parameters, that you can change for each child AI. If you want to change them for all instances, change them in the class blueprint.
There are 4 stages — setting skeleton, animation blueprint, AI blueprint and behavior.
If you want your Enemy AI to have a weapon, you should make a socket for it. To make a socket, press RMB on desired bone, choose Add Socket and enter the socket name. This name will be used in WeaponSocketName in NPCTable. You can preview any mesh in this socket, just press RMB on the socket and then Add Preview Asset.
In Enemy AI Constructor we sync AI behavior with animation with these 3 parameters:
Set notifies in animation, call methods (allowTaskChange, allowDamage and allowRotation) and pass them PawnOwner using TryGetPawnOwner. There is Mannequin example in the project.
Here you can change hitbox, target sphere and melee attack hemisphere.
The last step — set the type of Enemy AI. Just call IMeleeEnemy, IRangeEnemy или IMagicianEnemy after Event BeginPlay. Also, you must pass a projectile type to IRangeEnemy, and a skill used as autoattack for IMagicianEnemy.
There are three behavior tress — MeleeBehavior, RangerBehavior и MageBehavior. If you want to create new unique behavior tree, then it’s Blackboard must be a child of EnemyBlackboard.
Below, you will find the description of all mechanics of Enemy AI Constructor and a list of events for each one.
If Enemy AI is in Patrol mode, it will choose a random point on NavMesh in Radius (PatrolRadius parameter) and move to it. If IsGuardian is set to true, AI will be bound to spawn point. If PatrolRadius = 0, AI will stand still util player arrives.
Events:
If AI is in chase mode, it follows the player and tries to reduce the distance to AttackRange until player leaves EndChaseRange.
Events:
If AI is in melee attack mode, it will attack the player in melee until he dies or leaves AttackRange.
Events:
If AI is in range attack mode, it will attack the player until he leaves it’s AttackRange or enters AlarmRange. Range attacks do not interrupt, AI leaves range attack mode after attack animation has ended.
Events:
This mode differs from basic range attack — weapon is not needed. AI uses magic skill as an autoattack.
Events:
If AI is in retreat mode, it will seek and move to the most distant point from the player in RetreatRange until player leaves AlarmRange or MaxRetreatTime timer is over.
Events:
If you want to change something in existing mechanics and make a completely unique logic, just override its events. For example, to make an AI Enemy which uses Meteor and Ring of Light skills we overridden StartRetreat and RangersAttack events.
If you want to completely override existing event, don’t use CallToParentFunction after Event. It’s shown on the screenshot above.