I’m having an issue currently which I can’t quite get my head around, I’m trying to pass an array as a parameter to a function which should only run on owning client.
When I define it like this:
UFUNCTION(Client, Reliable)
void Client_ScoreChangedUpdateHUD(TArray<FPlayerScores> playerScoreboard);
It says that it wants the array passed as a const reference, similar to how it wants them passed if it needs to be blueprint visible
But when I define it like this:
UFUNCTION(Client, Reliable)
void Client_ScoresChangedUpdateHUD(const TArray<FPlayerScores>& playerScoreboard)
It throws this linkage error:
error LNK2005: "protected: void __cdecl AIslanderPlayerController::Client_ScoresChangedUpdateHUD(class TArray<struct FPlayerScores,class FDefaultAllocator> const &)" (?Client_ScoresChangedUpdateHUD@AIslanderPlayerController@@IEAAXAEBV?$TArray@UFPlayerScores@@VFDefaultAllocator@@@@@Z) already defined in IslanderPlayerController.cpp.obj
Note that if I take out the UFUNCTION(Client, Reliable) - then it’s more than happy to compile, but when it’s a replicated function, it doesn’t like the array either as a pass by value, or as a pass by const reference.
So how do I pass an array as a parameter to a replicated function?