I’m trying to update animation from first person (for the client) and third person (for the server and other clients) at the same time. For example, when getting a pistol, I’m trying to hide the previous weapon, blend the animation and show the pistol.
I’m working on a multiplayer games, so there are customs events dedicated for the client and also for the server. Some variables needs to be changed from the server in order to avoid cheats. However, this can lead to problem “syncing” the variable values between the server and the client.
Up to now, to avoid the “Accesed None” problem, I’ve had to use delays when the server has updated a value. However, I really feel like it is a patch: I need to check if a variable is valid, if not, wait a few ms and check again until the variable is valid. I also don’t like to have these kind of loops where the game could freeze…
What’s the correct way of waiting that the variable is sent from the server to the client before going further in the code?
this is definitively a patch, and not a good one, cause if you have a ping spike, or something like this, you will have the issue.
Well there is multiple way to handle this.
A) Wait replication of the server :
For this, use repnotify to react on the replication of a variable.
Pro : Easy to implement
Con : Ping dependant, can be frustrating if it’s a movement ability like jump, as you will to have server input lag
B) Skip Owner replication :
For this, use Skip Owner condition.
This will allow to have X value for a variable on server and remote client, except for the owner, who can have Y value.
This is used to have you’r own instance of a variable, but the owner is in charge to update it.
It kinda like the movement, it’s very usefull to get rid off input lag, but you are not synchronised with the server, and this can lead to some bug if you don’t have a robust network architecture.
Pro : 0 input lag
Con : Can be tricky sometime to implement
You have some other way, like wait confirmation from RPC or checking for change every tick, but there are very specific, and most of the time bad.