# OnComponentBeginOverlap work for one character but fires multiple time for other

**URL:** <https://forums.unrealengine.com/t/oncomponentbeginoverlap-work-for-one-character-but-fires-multiple-time-for-other/428863>\
**Category:** Character & Animation\
**Tags:** oncomponentbeginover, capsule-component, collision-detection, unreal-engine, CPP, question\
**Created:** [July 7, 2018, 4:56am UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-work-for-one-character-but-fires-multiple-time-for-other/428863 "2018-07-07T04:56:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gameatro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gameatro](https://forums.unrealengine.com/u/Gameatro)\
**Post date:** [July 7, 2018, 4:56am UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-work-for-one-character-but-fires-multiple-time-for-other/428863/1 "2018-07-07T04:56:31Z")

</div>

I am using the OnComponentBeginOverlap to detect if the punches of my character are hitting other. I used this code for the player character for the function called by OnComponentBeginOverlap:

```
void AMyProjectCharacter::Damage(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
{

	AAI_Character * Enemy = Cast<AAI_Character>(OtherActor);
	if (Enemy)
	{
		if(OtherComp == Enemy->GetCapsuleComponent())
		{
			UE_LOG(LogClass, Log, TEXT("Player punched"));
			Enemy->UpdateHealth(-10.f);
		}
	}
	
}

```

It is working fine, the Player punch is logged only when the punch hits the enemy and after 5 punches the enemy is destroyed as my enemy health is 50. However i used the same for my enemy character:

```
void AAI_Character::Damage(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
{
	AMyProjectCharacter * MyCharacter = Cast<AMyProjectCharacter>(OtherActor);
	if (MyCharacter)
	{
		if (OtherComp == MyCharacter->GetCapsuleComponent())
		{
			UE_LOG(LogClass, Log, TEXT("Enemy punched"));
			//MyCharacter->UpdateHealth(-10.f);
		}
	}
	
}

```

But with each punch of the enemy, the function gets called many times(3-5 times). I dont get why is it happening. Both the capsule components are identical, For both, OnComponentBeginOverlap is called inside BeginPlay but still this is happenening. The OnComponentBeginOverlap are as follows:

```
void AMyProjectCharacter::BeginPlay()
{
	Super::BeginPlay();
	LeftCollision->OnComponentBeginOverlap.AddDynamic(this, &AMyProjectCharacter::Damage);
	RightCollision->OnComponentBeginOverlap.AddDynamic(this, &AMyProjectCharacter::Damage);
}

```

and

```
void AAI_Character::BeginPlay()
{
	Super::BeginPlay();
	LeftCollision->OnComponentBeginOverlap.AddDynamic(this, &AAI_Character::Damage);
	RightCollision->OnComponentBeginOverlap.AddDynamic(this, &AAI_Character::Damage);
}

```

can anyone please help me with my problem. I am new to ue and I found that the answerhub is quit unresponsive to questions. so please someone help me with this.
