Download

RPCs Functions fail compile

Hello. When I use RPCs I get this error. I can’t understand why it output.

Message log:



OpenCode_MultiplayerCharacter.gen.cpp.obj : warning LNK4006: "protected: void __cdecl AOpenCode_MultiplayerCharacter::TestServerRPCs(void)" (?TestServerRPCs@AOpenCode_MultiplayerCharacter@@IEAAXXZ) ??? ????????? ? OpenCode_MultiplayerCharacter.cpp.obj; ?????? ??????????? ?????????
     ????????? ?????????? E:\UnrealEngineProjects\OpenCode_Multiplayer\Intermediate\Build\Win64\UE4Editor\Development\OpenCode_Multiplayer\UE4Editor-OpenCode_Multiplayer-9103.lib ? ?????? E:\UnrealEngineProjects\OpenCode_Multiplayer\Intermediate\Build\Win64\UE4Editor\Development\OpenCode_Multiplayer\UE4Editor-OpenCode_Multiplayer-9103.exp
  [6/7] UE4Editor-OpenCode_Multiplayer-9103.dll
  OpenCode_MultiplayerCharacter.gen.cpp.obj : error LNK2005: "protected: void __cdecl AOpenCode_MultiplayerCharacter::TestServerRPCs(void)" (?TestServerRPCs@AOpenCode_MultiplayerCharacter@@IEAAXXZ) ??? ????????? ? OpenCode_MultiplayerCharacter.cpp.obj
     ????????? ?????????? E:\UnrealEngineProjects\OpenCode_Multiplayer\Intermediate\Build\Win64\UE4Editor\Development\OpenCode_Multiplayer\UE4Editor-OpenCode_Multiplayer-9103.suppressed.lib ? ?????? E:\UnrealEngineProjects\OpenCode_Multiplayer\Intermediate\Build\Win64\UE4Editor\Development\OpenCode_Multiplayer\UE4Editor-OpenCode_Multiplayer-9103.suppressed.exp
  OpenCode_MultiplayerCharacter.cpp.obj : error LNK2001: ????????????? ??????? ?????? ""public: virtual void __cdecl AOpenCode_MultiplayerCharacter::TestServerRPCs_Implementation(void)" (?TestServerRPCs_Implementation@AOpenCode_MultiplayerCharacter@@UEAAXXZ)"
  OpenCode_MultiplayerCharacter.gen.cpp.obj : error LNK2001: ????????????? ??????? ?????? ""public: virtual void __cdecl AOpenCode_MultiplayerCharacter::TestServerRPCs_Implementation(void)" (?TestServerRPCs_Implementation@AOpenCode_MultiplayerCharacter@@UEAAXXZ)"
  E:\UnrealEngineProjects\OpenCode_Multiplayer\Binaries\Win64\UE4Editor-OpenCode_Multiplayer-9103.dll : fatal error LNK1120: ????????????? ??????? ?????????: 1


OpenCode_MultiplayerCharacter.h:




#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "OpenCode_MultiplayerCharacter.generated.h"

class UInputComponent;

UCLASS(config=Game)
class AOpenCode_MultiplayerCharacter : public ACharacter
{
    GENERATED_BODY()

public:
    AOpenCode_MultiplayerCharacter();

protected:
    virtual void BeginPlay();

protected:
    UFUNCTION(Server, Unreliable)
    void TestServerRPCs();

protected:
    virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;

public:
    FORCEINLINE class USkeletalMeshComponent* GetArms_Mesh() const { return Arms_Mesh; }
    FORCEINLINE class USkeletalMeshComponent* GetMainWeapon() const { return MainWeapon; }
    FORCEINLINE class UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
};


OpenCode_MultiplayerCharacter.cpp:



#include "OpenCode_MultiplayerCharacter.h"
#include "Animation/AnimInstance.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
#include "Components/InputComponent.h"
#include "GameFramework/InputSettings.h"
#include "HeadMountedDisplayFunctionLibrary.h"
#include "Kismet/GameplayStatics.h"

DEFINE_LOG_CATEGORY_STATIC(LogFPChar, Warning, All);

AOpenCode_MultiplayerCharacter::AOpenCode_MultiplayerCharacter()
{
    GetCapsuleComponent()->InitCapsuleSize(50.f, 96.0f);
}

void AOpenCode_MultiplayerCharacter::BeginPlay()
{
    Super::BeginPlay();
}

void AOpenCode_MultiplayerCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
    check(PlayerInputComponent);
}

void AOpenCode_MultiplayerCharacter::TestServerRPCs()
{

}


Your header file is correct, but the source file is wrong. RPCs actually get transformed into <RPC>_Implementation and, optionally, <RPC>_Validation when UHT is done parsing the file.

So, as the linker says, you need to make your method implementation:



void AOpenCode_MultiplayerCharacter::TestServerRPCs_Implementation()
{

}


You would normally have a _Validation method as well, but since you mark the RPC as unreliable - that isn’t required.