Search public documentation:
Last tested on UDK Mar, 2011
There are some special rules that should be observed when you are dealing with variable replication within your game.
Vectors are sent over the network is three signed integers rounded up to the nearest value. Replicated vectors can only stay within the bounds of (X=-1048576.f, Y=-1048576.f, Z=-1048576.f) and (X=1048575.f, Y=1048575.f, Z=1048575.f). Values that go above or below this range are clamped upon sending. If further precision or larger bounds are required then you will need to create your own struct with three floats in it or to simply send each component separately. Here is what the server is sending to all clients.
Rotators are sent over the network as three unsigned bytes. Thus the smallest unit transferred is 256 unreal unit rotation or 1.406250 degrees or 0.024543 radians. Although some precision is lost, the difference is so small that it is not visually noticeable. The calculation per component is done as replicated_component = (component >> 8) & 255. This will change any value, positive or negative, into a value between 0 and 255. On the receiving side, it is done as component = (replicated_component << 8). If further precision is required then you will need to create your own struct with three integers in it or to simply send each component separately. Here is what the server is sending to all clients. To double check, RotatorTest:
- 59467 >> 8 == 232
- 232 & 255 == 232
- 232 << 8 == 59392
- 9170 >> 8 == 35
- 35 & 255 == 35
- 35 << 8 == 8960
- -12242 >> 8 == -48
- -48 & 255 == 208
- 208 << 8 == 53248
Structs are sent over the network in a single pass. Other than vectors and rotators, they are not specially compressed in any other way. Structs are either sent all at once or not at all. Thus it is not possible to update a single component of the struct and then only send the changes. You can still do this manually however by sending individual variables and then compositing them together in the struct. Thus, in general be careful when replicating large structs. Here is what the server is sending to all clients.
Static arrays are sent over the network efficiently by only sending the changed values. This rule however is overridden if the static array is within a struct, due to the "all or nothing" rule attached to structs. Thus avoid large static arrays within structs, as then the entire struct is sent even if a single array value is changed. Replicated static arrays must be less than 448 bytes. Thus some static arrays of structs cannot be sent due to this restriction. Replicated notification of static arrays only work on the first initial replication update. Subsequent static array replication updates do not call ReplicatedEvent. However, if other replication notified variables call ReplicatedEvent, the static arrays then also call ReplicatedEvent. Static arrays within structs will always called ReplicatedEvent. Thus, if you are finding that static arrays aren't calling ReplicatedEvent at the appropriate times, replicate a boolean at the same time to make sure that ReplicatedEvent is called. Here is what the server is sending to all clients.
Dynamic arrays are not replicated at all. If you need to send a dynamic array of actors, you can use linked lists to do this. Otherwise, you may need to create your own replication method. One method is to do it via remote procedure calling, but you can easily overload the bandwidth available to you. Thus, dynamic arrays should be reserved for non replicating situations.
- Download the source code. (ReplicationVariableExample.zip)