Onoverlapbegin fires in all clients in listenServer?

Hi, I’m trying to make onoverlapbegin fires only in the client that made overlap happen.

I’m overriding OnOverlapBegin in C++ with the code below.

void AMyPickups::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
Super::OnOverlapBegin(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep,SweepResult);
	UE_LOG(LogTemp,Warning,TEXT("fire"));
}

this code fires in all clients so if i run game with 3 people in listen server, it fires three times

and i don’t have a clue about why it is happening.

i just want it to fire only in client that made this occur.

is there any way to make it happen only in one client ?

Of course it runs on all clients, because your item and each character are replicated to all clients and they all have their separate functionalities.

In any case, you can check if your character is locally controlled before firing the overlap function. Something like:

void AMyPickups::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
    AMyCharacter* MyChar = Cast<AMyCharacter>(OtherActor);
    if (MyChar != nullptr)
    {
        if (MyChar->IsLocallyControlled())
        {
            // your code here
        }
    }
}

Thanks for help, it works!

but another problem happend, if i activate my custom function in OnOverlapBegin

editor says “No owning connection for actor MyPickups_BP_2”

oh it was my mistake to put setreplicated in playerController. everything good now Thanks!