I am running into problems trying to update all clients’+players’ GUI’s after having set the important ‘Life’ variable in my GameState.
I set this using an RPC so that I knew the client would get the right value.
But now when I try to refresh the GUI’s, the client ones do not yet have the updated variable so fails to set with the correct number.
Does anyone know a good simple foolproof way of doing this, avoiding guesses with ‘Delay’ etc.
When you say ‘proporties’ do you mean ‘variable’ replication? (of course they can also be a wide range of data and object types etc)
If I do an OnRep_ thing would that ensure that it executes (on the client) once the variable has safely reached the client?
Don’t know why I didn’t try that, I had a bit of a mess to deal with so forgot about rep notify’s.
OnRep calls the bound OnRep_ Function once the Variable reaches the Client.
So yes, this is exactly meant to be used when you need to ensure that the value is replicated.
On the other hand, I’m kinda confused that RPCs, in which you pass a value, don’t pass the correct value.
Cause I’m using RPCs to pass values from Clients to Server and other way round for a long time and I
never had a race condition, as I’m directly passing the value.
The only part where race condition comes in is setting a normal replicated variable and then calling an RPC
after that. Then it can be that the RPC is called before the value is replicated.
Yes so it’s of course OnRep that I should have used, silly me.
The RPC generated and passed down the correct value. It was just me trying to use the value too quickly before it had reached the client. (I actually called the ‘consumer function’ at the end of the RPC itself and figured that would work, but it didn’t)
Shouldn’t be a problem with OnRep.