RepNotify variables in a loop only shows the last index changes to newly joined players.

I’am new to multiplayer and replication, I have multiple actors in my map and each one have a Widget component to display a specific widget based on a data i am looping on, I want to make my dedicated server responsible for setting each of these actors widgets so when other players join they find these widgets already spawned and replicated to all players.
I managed to replicate these actors using Switch has authority node and then run a loop on my data and set each actor widget one by one, the issue is if players join when the server just started and be present while the process is running for the first time everything goes perfect , but when i reconenct one player i only find the last index actor of the loop displayed since i’am using RepNotify which makes sense, what i am struggling to do is how can i let any latejoining player see the whole displayed loop/actors. I dont have that much experience in replication and i looked everywhere and i didnt find any similar situations so can anyone help me with the logic please

I am guessing you havent seen this guy on YouTube yet.

Hello, thanks for your reply.
I did watch that video like a 100 time and i do understand how to implement replication to my actors but the exampls he show in his videos are very simple and as i said i am struggling to implement the logic since it is a complex case.
I have a loop once that loop finishes any player that joins only sees the last index of that loop replicated but not the rest of the array so i’am wondering how can i make sure everything stays replicated from the start to the end of the loop.

we might need to see some code, RepNotify will work for late joiners so something else is likely wrong

Hello Auran,
Alright here is a code breakdown (sorry if it is messy i tested a lot of things )
I start by calling a custom event after OnBeginPlay that fetch my Data using an API.

Then once i retrieve my data Array i pass it to nother custom event to break down the data
image

then i created a variable to replicate my data by setting it and using the repnotify function to make the logic when it is changed like so :
image

and here is the logic for the data RepNotif :
image

GetChart basicaly just make a loop on my data using a specific timer , i didnt use basic loops so i dont spawn my actors in a single frame because i had some issues with the outcome.(it is a long code so i’ll seperate it to 3 parts)
Part 1 :

Part 2 :

Part 3 :

Now i use the Repnotify on the Type of Chart variable to start setting the specific widgets
Since i have two possible type of actors (either main monitor or a normal one) i made two Arrays that reference an exisitng actors of each type in my map and i made two counters like so

now on each counter Repnotify I made the logic of spawning


and finally the struct that contains the data of each monitor i set it in the bleuprint of the actor itself so it start the Repnotify logic
Part 1 :

Part 2 :

and the logic is the same for the other chart type it is just a big chunk fo nodes

I know it is too long but i am kind of lost on where the issue could be. i would apreciate some help.

so much going on here ha,

  1. RepNotify with arrays Doesn’t run on server, weird I know but you’ll have to call the function manually.

  2. you have lots of things replicated that probably shouldnt be, like the timer and index etc. the server could be overriding the client so it jumps to the last index.

  3. its hard to jump into someone elses code but all of this should probably only be run on server anyway, all you want to replicate is the result.

so the server goes through the loop, updates all the variables, like in a struct. RepNotify the struct or array of structs and clients update their widgets etc

I see , thanks for taking the time and reading my code I realy appreciate it.
I will try this :

  1. i ll make the server go through the loop and get the data
  2. make a struct that has a RepNotify (struct will contain an array of monitors and an array of MonitorDataStruct )
  3. Set each refenrenced monitor and its opposite in the arrays of the struct (something like ReplicatedStruct.MonitorArray[0] its opposite is ReplicatedStruct.MonitorDataStructArray[0])
  4. Each client will have that struct filled to spawn the monitors from it using the Struct RepNotify logic.

Would this be better ?

It worked you are the GOAT, Thanks !

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.