When one of my enemies takes damage the other one also does.
.h File
#pragma once
#include "GameFramework/Character.h"
#include "EnemyCharacter.generated.h"
UCLASS()
class MYPROJECT_API AEnemyCharacter : public ACharacter
{
GENERATED_BODY()
int enemyHealth;
...
}
C++ File
void AEnemyCharacter::BeginPlay()
{
Super::BeginPlay();
enemyHealth = 10;
...
}
void AEnemyCharacter::OnOverlapBegin(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
enemyHealth = enemyHealth - 1;
...
}
This might not be related but another thing that happens is when I finish off their health the same one dies no matter which one I hit last.