Created
April 1, 2012 22:25
-
-
Save LoganBarnett/2279136 to your computer and use it in GitHub Desktop.
Syncs Droid movement over the network using dead reckoning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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