I'm trying to replicate GameInstance subSystem, before i achived that for…
- User
I'm trying to replicate GameInstance subSystem, before i achived that for worldSubsystem. But i can't achive that with this error: [2024.10.10-13.33.24:340][429]LogWindows: Error: Object ScenarioSubsystem None created in SV_ScenarioSystemHandler instead of GameInstance Code for object which needed for replication: ASV_SubsystemReplicator::ASV_SubsystemReplicator() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bStartWithTickEnabled = true; PrimaryActorTick.bCanEverTick = true; bReplicates = true; bAlwaysRelevant = true; bReplicateUsingRegisteredSubObjectList = true;
}
// Called when the game starts or when spawned void ASV_SubsystemReplicator::BeginPlay() { Super::BeginPlay();
ReplicateSubsystems();} void ASV_SubsystemReplicator::Tick(float f) { Super::Tick(f); auto g=GetSubsystems(); } void ASV_SubsystemReplicator::ReplicateSubsystems() { if (!HasAuthority()) { return; }
AddSubsystemToReplicatedList(GetWorld()->GetSubsystem<UScenarioSubsystem>()); AddSubsystemToReplicatedList(GetWorld()->GetSubsystem<UDialogSubsystem>());}
void ASV_SubsystemReplicator::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ASV_SubsystemReplicator, Subsystems);}
SubSystem replication part:
virtual bool CallRemoteFunction(UFunction* Function, void* Parameters, struct FOutParmRec* OutParams, FFrame* Stack) override; virtual int32 GetFunctionCallspace(UFunction* Function, FFrame* Stack) override; virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override; virtual bool IsSupportedForNetworking() const override { return true; }private: UPROPERTY(ReplicatedUsing = ONRep) TObjectPtr SubsystemReplicator; public: void SetSubsystemReplicatorActor(AActor* Outer); UFUNCTION() void ONRep();
void UScenarioSubsystem::SetSubsystemReplicatorActor(AActor* Replicator) { this->SubsystemReplicator = Replicator;
}
void UScenarioSubsystem::ONRep() { //todo return; }
bool UScenarioSubsystem::CallRemoteFunction(UFunction* Function, void* Parameters, FOutParmRec* OutParams, FFrame* Stack) { if (OuterActor) { if (UNetDriver* NetDriver = OuterActor->GetNetDriver()) { NetDriver->ProcessRemoteFunction(OuterActor, Function, Parameters, OutParams, Stack, this); return true; } } return false; }
int32 UScenarioSubsystem::GetFunctionCallspace(UFunction* Function, FFrame* Stack) { if (OuterActor) { return OuterActor->GetFunctionCallspace(Function, Stack); } return FunctionCallspace::Local; }
void UScenarioSubsystem::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps);
- Assistant