I have a loot box blueprint, which has a boolean flag variable bCanLoot, marked with RepNotify/Replicated to indicate this thing has already been looted or not.
1)While clientA and clientB are both online, and clientA looted, clientB will get the correct “false” value(I use displayall to see the value). 2)While clientA looted before clientB connected, clientB will see wrong value of “true”, while on the server this is already “false” since clientA looted.
How can I get “false” as the server in clientB in situation 2)?
I also have a health value in native code, marked as Replicated, but this work as expected: when clientB connected after clientA get damaged, clientB sees the changed health value.
So is this a bug in BP’s variable or I missed some settings?
After some more network & replication doc reading and debugging in different directions, I found it’s because the loot box was set to hidden. So later when another client connected, it will be ignored in replication, as per code in AActor::IsNetRelevantFor:
else if( bHidden && (!RootComponent || !RootComponent->IsCollisionEnabled()) )
We think this post contains useful information which we would like to share with our public UE4 community. With your approval, we would like to make a copy of this post on the public AnswerHub which includes the discussion but strips out your username and company name. Please let us know if you are okay with this.
It’s my pleasure that I can contribute to the community, and that’s why I left this self ask-answer here. And I don’t care you strip these personal info or not. Please go ahead with the post copy thing.