Let's go back to Unreal Engine and focus on Content Browser. We now need an opponent. To add this, follow these steps:
Right-click and select Blueprint.
At the lower end of the window, let's drop all the classes and search for AIController.
Select AIController under Controller and hit Select in the lower-right corner.
We will name this AIController
Enemy
.Open
Enemy
AIController and go to the EventGraph section.
First, we must find Hero and then store it in a local variable to be used at any time. To do so, follow these steps:
Right-click in an empty area within EventGraph and search for Event Begin Play.
Pull from the exec pin and search for Get All Actors Of Class.
Set the Actor Class pin to Hero.
Pull from the Out Actors array and search for ForEachLoopWithBreak:
We want a filter for the Hero
class within the MyCharacter
pawn returned. To do so, follow these steps:
Pull from the Array Element pin and search for Cast to MyCharacter.
Then, pull from the As My Character pin and search...