hello I have a replicated function but it has many errors with LNK
character.h
#include "Net/UnrealNetwork.h"
#include "Engine.h"
#include "GameFramework/Character.h"
#include "MyCharacter.generated.h"
UFUNCTION(Server, WithValidation)
void ReplicatedFunction();
character.cpp
#include "MyCharacter.h"
void AMyCharacter::ReplicatedFunction_Implementation()
{
//do stuff
}
bool AMyCharacter::ReplicatedFunction_Validate()
{
return true;
}
Are you compiling from Visual Studio or from within the Editor.
Try compiling from within the editor.
You forgot the reliable keyword within the macro
UFUNCTION(Server, Reliable, WithValidation)
First things first, don’t include UnrealNetwork.h
in your header file. Also please remove Engine.h
from your header file and replace it with CoreMinimal.h
!
Second thing, the correct line is
UFUNCTION(Server, Reliable)
void ReplicatedFunction();
WithValidation is no longer required unless you want to specifially return false. So just ommit it.
In your cpp file, add #include UnrealNetwork.h
and remove the
bool AMyCharacter::ReplicatedFunction_Validate()
{
return true;
}
This is new in later engines (the non-requirement for WithValidation) and i see you are using 4.24.