Hi, I have built a multiplayer game using a dedicated server.
When a client changes the colour of something (using rep-notify) all other clients see this when they are online together. However if a new client joins the server later they don’t see that new colour - they only see the base colour (unchanged).
The position of moved objects (these are updated on-tick) are seen by newly joining clients however so not everything is ignored.
How do I ensure that any newly joined client captures all updates to the server ?
I have seen a ‘get gamestate’ node but am not sure how to implement that if it is the solution.
Any hints or tips to help me understand this would be very helpful.
RepNotify Variables should be replicated to new joining clients. The actor that’s being changed must also be replicated. If placed in the map “net load on client” must be ticked.
Thank you for taking the time to look at this. The colour change is actually part of the player pawn blueprint - it is a unique identifier for each player. As such I had assumed that the colour would be seen by newly joining clients when using rep-notify from the server. I just tried replicating the two colour material variables but that didn’t work. Here is the code:
sorry, maybe my example wasn’t very good. things to know:
if you have properties with rep notify function that sets something up then remember that first rep notify will fire before BeginPlay, which makes it easy to miss. If you use BeginPlay you should call your rep notify method from there ‘manually’.
other thing: assigning same value to replicated property on server won’t cause rep notify, at least for simple types, assigning TArray with ‘same’ elements will rep.
The Dynamic Material Instances should be created in the Construction Script.
Replication Subsystem doesn’t care if your class is ready or not to receive the replicated variables. It checks if there are properties to replicate and sends.
The onrep function needs to validate the DMI references and you should have a Set Vector Param for each. Don’t double up on targets.
OnRep_Current Colour:
Colour Material → Isvalid → Set Vector Param (Current Colour)
Colour Material 02 → Isvalid → Set Vector Param (Current Colour)
Print String(replicated), duration 5 seconds.
Everything else looks fine.
Here’s an example from one of my projects.
The repnotify var is an ID. I use it for data table look up which spits out a cosmetic struct. Then I run a Sequence.
Then 0 checks if the DMI’s are Valid. If not they are created and set.