It just wont call the ServerFunction
Character.h
UPROPERTY(EditAnywhere)
class UActorComponent* ActorComp = nullptr;
void CallActorCompFunc();
Character cpp
ActorComp = CreateDefaultSubobject<UActorComponent>(TEXT("ActorComp"));
if (ActorComp)
{
ActorComp->SetIsReplicated(true);
}
void ACharacter::CallActorCompFunc()
{
ActorComp->Function();
}
ActorComponent.h
void Function();
UFUNCTION(Server, Reliable)
void ServerFunction();
ActorComponent cpp
UActorComponent::UActorComponent()
{
SetIsReplicated(true);
}
void UActorComponent::Function()
{
ServerFunction();
}
void UActorComponent::ServerFunction_Implementation()
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Purple, TEXT("ServerFunction called"));
}
i have been reading that it might be because of the Actor Component not having an owner
The actor component is calling the server function is this wrong
Is the character the only one that can call server functions
irajsb
(irajsb)
4
SetIsReplicatedByDefault
(
const bool bNewReplicates
)
this is how you set replicate in constructor. set relevancy to always relevant .
Would it be because of the actor component not being replicated
I set
SetIsReplicatedByDefault(true)
But it didn’t do anything and the server function isn’t being called
i dont know what type of **sorcery ** and witchcraft this is but
i found a solution
all i did was crate a server function in character.
CallActorCompFunc called the new character serverfunction which then called the component function and it worked
Dont know why