Controlling the player character to attack
When you created the Pangaea project, the engine automatically generated the PangaeaPlayerController
class so that you had basic control over the player character. To understand how PangaeaPlayerController
controls the player, let’s open the PangaeaPlayerController.cpp
file in Visual Studio (VS) and look at the code.
First of all, the SetupInputComponent()
function binds the OnSetDestinationPressed()
and the OnSetDestinationReleased()
event handler functions to the SetDestination action defined in the project’s input settings. These two event handler functions call the movement functions, StopMovement
and SimpleMoveToLocation
, to move the character toward the next new destination.
Can we add a new attack action to the system and hook it up to our own handler function? The answer is yes. Let’s start by defining the new attack action.
Adding the Attack action to the action map
In Unreal, PlayerController
is defined...