Controllers
In this example, we will give PlayerController the ability to take and apply damage. This is done once the AI is finished, and you'll be able to fight the AI. Also, as we will use AI Perception in this course, we should register the Stimuli source for our controller. Next, we will set up the AIController. We will give it the ability to sense stimuli. Then, we will create an Actor component, which will contain the function needed to update Behavior Tree.
Let's move on and begin to create these base components, as follows:
In the AI folder, right-click and select Blueprint. Then, from the options, select Player Controller. Then, we want to name this
OutController
.Open Event Graph and find Event BeginPlay.
Right-click nearby and search for Get Controlled Pawn. Then, pull from Return Value and search for Assign OnTakeAnyDamage.
This will create an OnTakeAnyDamage event and output Damage.
We need to create a variable to hold our Health variable. Click on Add variable and make a Float variable...