
LOO ZHENG-JIE

Unreal Showcase
|
C++ / Blueprint
Acknowldeging the importance of implementing c++ in Unreal Engine as a programmer, here are my array of Unreal Engine C++ oriented showcases.
Simple AI Patrol
The enemy is a character class that uses an AI controller. The patrol behavior is executed by the enemy behavior tree which stores the blackboard components that controls the data stored in the behavior tree. The blackboard component holds two patrol points which are vectors based on the world location. In the enemy class, the patrol points values are declared and assigned to the blackboard keys.


Using the "Move To" task node, the enemy character will move to the patrol point, with the delay of "Wait for" task node.
Simple AI Follow Player If Detected
The logic behind the enemy following the player is similar to the patrolling behavior. In the behavior tree, the enemy will execute the "Move To" task node in which the target is set to an "Object" blackboard component key. In order to execute the task, the target value must be valid.


The targeting system to implement for the enemy involves the calculation of the dot product between the enemy's forward vector and the vector of the player from the enemy (normalized). The dot product is then compared to the cosine of the angle of the enemy's viewing angle. If the player is within a threshold range and the dot product is more than / equals to the cosine value (radian), then the enemy will set the value of the target as the player character reference, hence making the execution of the following task as valid.


