Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Syncs Droid movement over the network using dead reckoning

View DroidController.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) {
if (stream.isWriting) {
var position = transform.position;
var rotation = transform.rotation;
 
stream.Serialize(ref movementSpeed);
stream.Serialize(ref currentHorizontalMovement);
stream.Serialize(ref currentVerticalMovement);
stream.Serialize(ref position);
stream.Serialize(ref rotation);
}
else {
Vector3 position = Vector3.zero;
Quaternion rotation = Quaternion.identity;
 
stream.Serialize(ref movementSpeed);
stream.Serialize(ref currentHorizontalMovement);
stream.Serialize(ref currentVerticalMovement);
stream.Serialize(ref position);
stream.Serialize(ref rotation);
 
transform.position = position;
transform.rotation = rotation;
 
useNetworkInput = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.