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 to the next 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:
- Right-click the
Content Browser
inside the editor and selectNew C++Â Class
. - Choose the
Character
class 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
, not return anything and only receive the AActor* TargetActor
parameter, which will be the actor it should be facing. Have a look at the following code snippet, which shows this function:
// Change the...