

#Unity required networkview to destroy full#
In order to implement full server authority in Unity Networking, we'll have to scrap the OnSerialize function in favor of RPCs. Our client is still sending raw position to other clients, rather than the server. PlayerScript.vertAxis = moveHistory.VerticalAxis PlayerScript.horizAxis = moveHistory.HorizontalAxis Void CorrectState( Vector3 correctPosition, NetworkMessageInfo info ) NetworkView.RPC( "CorrectState", nder, transform.position ) įinally, on the client we'll receive this CorrectState message, rewind back to the correct position, and replay all inputs from that point on to the current time. error is too big, tell client to rewind and replay If( Vector3.Distance( transform.position, position ) > 0.1f )

Void ProcessInput( float horizAxis, float vertAxis, Vector3 position, NetworkMessageInfo info ) If the position sent by the player is too far apart from the position calculated by the server, a message is sent to the client telling them to correct their state. On the server, we simulate the player, then compare the resulting position with the position sent by the player. Now, in FixedUpdate we'll grab the current move state, buffer it, call the Simulate function, then send the move state and the resulting position to the server. a reference to the Player script attached to the game object. a history of move states sent from client to server We'll also keep a reference to our Player script for the client and server: On the server, we'll store a buffer of move states sent from the client. Public move( float horiz, float vert, double timestamp ) represents a move command sent to the server First, we'll create a structure to hold move commands: Now that we have our script structured the way we need, we can go ahead and implement the rest. Implementing server authoritative movement
