During this session, I wanted to implement a health bar, similar to the player’s, for the enemy, as well as a death condition. Also I aimed to add smooth camera movement.
Enemy CPP file
void ACompetitionEnemy::Damage()
{
health = health - 25;
if (health <= 0)
{
Destroy();
This simple damage function uses the same method as the player damage. On called the health is lowered and if the health is too low the enemy will be destroyed.
Player HUD Blueprint

Player CPP file
void ACompetitionCharacter::Punch(...)
{
...
if (ArmActive == false)
{
...
GetWorldTimerManager().SetTimer(CameraHandler, 1.0f, false);
GetWorldTimerManager().SetTimer(PunchTimerHandle, this, &ACompetitionCharacter::ResetPunch, 1.0f, false);
...
void ACompetitionCharacter::ResetPunch()
{
GetWorldTimerManager().SetTimer(MovementHandler, this, &ACompetitionCharacter::ResetControl, 1.0f, false);
...
if (ArmActive == true)
{
PunchingArm->DestroyComponent();
Here I have added “CameraHandler”, which will be used to carry out my camera movement interpolation later. Also upon finishing, “PunchTimerHandle” will activate “ResetPunch”, which will destroy the arm if it exists and set a timer for a function that gives the player back control.
void ACompetitionCharacter::Tick(float DeltaTime)
{
...
//if Camera time is running
if (GetWorld()->GetTimerManager().IsTimerActive(CameraHandler) == true)
{
//if punching
if (ArmActive == true)
{
//interpolate spring arm
SpringArm->SocketOffset = FMath::VInterpConstantTo(FVector(0, 0, 50),CameraTempPos, GetWorld()->GetTimerManager().GetTimerElapsed(CameraHandler), 200.f);
SpringArm->TargetArmLength = 100;
}
//if retreating
if (ArmActive == false)
{
SpringArm->SocketOffset = FMath::VInterpConstantTo(CameraTempPos, FVector(0, 0, 50), GetWorld()->GetTimerManager().GetTimerElapsed(CameraHandler), 200.f);
SpringArm->TargetArmLength = 100;
}
While the timer is active and the punch is being carried out (“ArmActive == true”), the camera socket offset is constantly interpolated to reach the desired location. And if the timer is active but the punch isn’t, it is assumed the punch has ended and the camera will interpolate back to the original position.
I had many issues while trying to implement this feature, mostly centered around constantly interpolating. But I finally found out I could use a timer and constantly check its progress in the tick function to match up with my interpolation process.