Performance: Remote procedure calls
MEDIUM IMPACT
Remote procedure calls affect network latency and responsiveness in multiplayer or distributed Unity applications.
void Update() {
if (Time.time - lastSent > 0.1f) {
CmdSendPosition(transform.position);
lastSent = Time.time;
}
}
[Command]
void CmdSendPosition(Vector3 pos) {
RpcUpdatePosition(pos);
}
[ClientRpc]
void RpcUpdatePosition(Vector3 pos) {
transform.position = pos;
}void Update() {
CmdSendPosition(transform.position);
}
[Command]
void CmdSendPosition(Vector3 pos) {
RpcUpdatePosition(pos);
}
[ClientRpc]
void RpcUpdatePosition(Vector3 pos) {
transform.position = pos;
}| Pattern | Network Calls | Latency Impact | Bandwidth Usage | Verdict |
|---|---|---|---|---|
| Send RPC every frame | High (60+ per second) | High latency and lag | High bandwidth usage | [X] Bad |
| Send RPC at fixed intervals | Low (10 per second) | Lower latency | Reduced bandwidth usage | [OK] Good |