I have a really simple setup:
PlayerPawn.h
UFUNCTION(Server, Reliable)
void AttackPiece_Server(AParentPiece* Attacker, AParentPiece* Defender);UFUNCTION(NetMulticast, Reliable) void AttackPiece_Multicast(AParentPiece* Attacker, AParentPiece* Defender);
PlayPawn.cpp (sorry, formatting isn’t working)
void AMatch_PlayerPawn::AttackPiece_Server_Implementation(AParentPiece* Attacker, AParentPiece* Defender)
{
if (IsValid(Attacker) && IsValid(Defender))
{
AttackPiece_Multicast(Attacker, Defender);UE_LOG(LogTemp, Error, TEXT("Called on server."));
}
}void AMatch_PlayerPawn::AttackPiece_Multicast_Implementation(AParentPiece* Attacker, AParentPiece* Defender)
{
UE_LOG(LogTemp, Error, TEXT(“Called on client with %s.”), *this->GetName());Camera->SetWorldLocation(FVector(0.0f, 0.0f, 1000.0f), false, nullptr, ETeleportType::None);
}
So I call a server function on the player pawn, which executes some server-only code. Then it calls a multicast function that’s supposed to call code that every client needs to execute.
It seems like it all works: “Called on server” prints at the right time, followed by a “Called on client with ___” for each player pawn. But all of the code I’ve tried executing after that UE Log in the multicast doesn’t work. The log gets called on every client, but subsequent code only gets called on the client that called the original server function. It’s as if I put a “IsLocallyControlled” gate right after the log, which I obviously didn’t.
The only thing I can think of is a problem replicating or accessing the player pawn? Even though the pawn successfully replicates across all clients, except for this one function now. Does anyone know what could be wrong?
Thanks in advance!