Rotation via RPC and wrong result angle

Hi there,

I have a problem with sending transform rotation using RPC.

Basically, I try to get the mouse input for Y axe when rotating the clone on the client, and rotate the clone on server using this value via RPC.

The rule it’s apparently working, but the final rotation angle on the server is a bit (more or less) different from the rotation on client. Why?

Here is the essential part of code I use:

// Transform components

// --------------------
// CharacterMotor.js
// --------------------

var getUserInput : boolean = true; // false on Server, true on Client

var rotateInput : float;

function Update () {
	if (getUserInput) { 
		rotateInput = Input.GetAxis("Mouse X"); 

	// rotateInput by RPC on Server, by Input on Client
	transform.Rotate(0, rotateInput, 0); 


// --------------------
// NetworkController.js // active on Client only 
// --------------------

var rotateInput : float;
var lastRotateInput : float;

var targetController : CharacterMotor; // (above, assigned)

function Update() {

	rotateInput = Input.GetAxisRaw("Mouse X");

	if (rotateInput != lastRotateInput) {
		Debug.Log("Send rotation: " + rotateInput); 
		networkView.RPC("SendRotation", RPCMode.Server, rotateInput);
	lastRotateInput = rotateInput;

function SendRotation(rotateInput : float) {
	Debug.Log("Receive rotation: " + rotateInput); 
	targetController.rotateInput = rotateInput;


Start/Stop rotation on Client. Debug.Log reports looks ok:

Send rotation: 0.2,  Receive rotation: 0.2

Send rotation: 0.9, Receive rotation: 0.9

Send rotation: 0.3, Receive rotation: 0.3

Send rotation: 0,25, Receive rotation: 0.25

Send rotation: 0.05, Receive rotation: 0.05

Send rotation: 0, Receive rotation: 0


Final Y angle reported on Client = 25.5

Final Y angle reported on Server = 24.75

What is reason of this difference?

Thanks in advance,


The difference is probably due to latency.

I believe you’ll want to use state synchronization rather than RPC for this, however.

This is not exactly what RPC were meant for.