I am just coming back to UE4 after last working with 4.5. I’m currently using 4.9.1 and I am unable to build any code with RPCs in it. Based on the transition guides on the c++ forums, the way they are declared has changed, but even doing so it will not compile.
UCLASS()
class UE4PLAYGROUND_API ANetTest : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ANetTest();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// Old Implementation, doesn't work. Expected.
//UFUNCTION(Server, Reliable, WithValidation)
//void RPC1();
UFUNCTION(Server, Reliable, WithValidation)
void RPC2();
bool RPC2_Validate();
void RPC2_Implementation();
// Newest implementation
//UFUNCTION(Reliable, Server = "RPC3_I", WithValidation = "RPC3_V")
//void RPC3();
//bool RPC3_V();
//void RPC3_I();
};
As you can see, I tried all 3 methods to no avail. RPC1 doesn’t work for the obvious lack of declaration of the validate and implementation functions. RPC2 and RPC3 generate the following error:
1>\UE4Playground.generated.cpp.obj : error LNK2005: “public: void __cdecl ANetTest::RPC2(void)” (?RPC2@ANetTest@@QEAAXXZ) already defined in NetTest.cpp.obj
I have tried deleting the previous build before building.
Name does not have any bearing on the result. Creating a new class does nothing. I was able to get it to build with a separate project using GENERATED_UCLASS_BODY and the pre 4.7 style declaration even though I’m pretty sure both were supposed to be deprecated. Regardless, that is not the case in this project, it fails either way. Not sure if this is me doing something stupid or if I have a corrupt build.