Let’s say we have a BeginOverlap:
void AMyActor::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
// Check if reader own the pawn
if (ACharacter* OtherActorAsCharacter = Cast<ACharacter>(OtherActor))
{
if (APlayerController* PCRef = Cast<APlayerController>(OtherActorAsCharacter->GetController()))
{
if (PCRef->GetHUD())
// do something
}
}
}
What I mean with this piece of code is that I wan’t to know whether the “OtherActor”, which is a Character, is the one that is reading this piece of code. In a BeginOverlap, if we wanna run this piece of code only for the player that is being overlapped, I see we have two choices:
Call a Client RPC on pawn or, as I did, get the HUD (since only the owner can see the hud). There is any other way, faster and cleaner?