Multicast being called before replicating variable

so i just found a very simple problem with replication and multicast…
when setting a replicated variable and calling a reliable multicast after it, the multicast gets called on clients but it isn’t using the new replicated value, like if the multicast got called first even tho i called the set node first

To fix this i had to add a delay between setting and multi-casting, but it isn’t a fancy solution and i don’t like it.
Another way to fix this is to uncheck the RELIABLE box from the multicast but i also don’t like that

i tried calling the multicast first and then the set node but when i do this unreal crashes instantly, i tried it 2 times already.

am i doing something wrong? or is this a bug and should i open a ticket?

no answers?

Hi, Nico_Pucho_27! Could you show me the Multicast function you are running?

Hi again, instead of getting the variable ‘Currentgun’ normally try to get it through the function,
Hope this helps :smiley:

Hi, Nico_Pucho_27!
That is exactly what I mean! :smiley:
If that doesn’t work then there might be a problem with setting the variable, however that is very unlikely.

sure! it simply hides an array of static meshes and then only shows one of them

the problem is that it shows the previous current mesh and not the new one

you mean adding the variable as an input of the function?

RepNotify is what you are looking for when you want something to happen when the variable is changed. The caller is not responsible for when it arrives so just because you call it in order doesn’t guarantee it arrives in that order. It is not a bug it is just how networking works.

so multicast functions haves more priority than replicated variables?

and what if a variable is = 0 and i set it again = 0? the engine is not notifying the players because the variable didn’t change, but i still want to execute the code inside the On Notify function

In that case you want to use only the Multicast with the variable as a parameter and not RepNotify

thanks! could you take a look at this question too?

Pass the CurrentGun through the multicast event as a parameter, set it on the handler side and then use it normally as you have it. That will sync the variable to be the same as what you set it to before calling the multicast at the moment the multicast is received.