Download

(RESOLVED) Possible Network Relevancy bug with JIP clients?

When setting an actor to hidden and removing its collision, the actor is no longer relevant so the the OnRep does not fire for a late joining client



this->SetActorHiddenInGame(true);
this->SetActorEnableCollision(!ObjectPickedUp);


Dedicated server btw
Here is what i have my code setup to do. The player walks up to an object, presses E and a line trace gets sent out from the players head. If the line trace hits something valid like a pickup item, the line trace is called to be performed on the server. If the server infact hits the pickup item from the line trace then it adds it to the players inventory.

How the inventory is setup:
Server calls a function on the players inventory component which adds the object to a TArray, and then calls a function on the pickup item itself that changes a replicated OnRep variable from false to true. The OnRep function simply disables collision and hides the object.
This works just fine for any client that is connected to the server where the object is relevant, but not for a join in progress client.

Let me explain:
There is client1, client2, and client3. Client1 and client2 are connected to the server, client3 is NOT. Client1 pickups one of the items so that the object is hidden and has collision disabled and client2 also sees that the object is hidden and has its collision removed. Client3 joins the server and still sees the object that client1 picked up that is suppose to be hidden with collision disabled. The OnRep event never fired for client3.

Heres what makes me question if its a possible relevancy bug:
If the object is set to always be relevant, the object would be hidden for client3 as the log shows that the OnRep event fired.

What could be the cause of this issue? heres some code to show you what i mean



//.h
UPROPERTY(ReplicatedUsing = OnRep_ItemInteracted)
        bool ObjectPickedUp;

    UFUNCTION()
        void OnRep_ItemInteracted();

void InInventory(bool In);//gets called from server to start OnRep event


//.cpp
APickups::APickups()
{
    MeshComp = CreateDefaultSubobject<UStaticMeshComponent>("StaticMeshComponent");
    RootComponent = MeshComp;

    IncreaseAmount = 30.0f;
    ObjectPickedUp = false;

    bReplicates = true;
}

// Called when the game starts or when spawned
void APickups::BeginPlay()
{
    Super::BeginPlay();

}

void APickups::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    DOREPLIFETIME(APickups, ObjectPickedUp);
}

void APickups::OnRep_ItemInteracted()
{
    UE_LOG(LogTemp, Warning, TEXT("ON REP FUNCTION FOR ITEM PICKUP"));
    this->SetActorHiddenInGame(ObjectPickedUp);
    this->SetActorEnableCollision(!ObjectPickedUp);
}

void APickups::InInventory(bool In)
{
    if (Role == ROLE_Authority)
    {
        ObjectPickedUp = In;
        OnRep_ItemInteracted();
    }
}