Creating the EnemyCharacter C++ class
In our Dodgeball game, the EnemyCharacter class will constantly be looking at the player character if they’re within view. This is the same class that will later throw dodgeballs at the player; however, we’ll leave that for the following chapter. In this chapter, we will be focusing on the logic that allows our enemy character to look at the player.
So, let’s get started as follows:
- Right-click on the Content Browser inside the editor and select New C++ Class.
- Choose the
Characterclass as the parent class. - Name the new class
EnemyCharacter.
After you’ve created the class and opened its files in Visual Studio, let’s add the LookAtActor function declaration in its header file. This function should be public and not return anything, only receiving the AActor* TargetActor parameter, which will be the Actor it should be facing. Have a look at the following code snippet, which shows this...