Unity multiplayer tutorial, physics calculations on server

Share

Creator and Proxy prefab and adding components

In the last step of this unity multiplayer tutorial we just created the RacketOwner prefab but the uLink.Network.Instantiate method that we will be using requires other two prefabs, the Creator and the Proxy. We will create them and we will see how they differ and what is their scope. For a start we will duplicate the prefab we created :

  1. Select the RacketOwner inside the Resources folder in the Project panel and duplicate it two times by pressing CTRL-D, then rename the two copies RacketCreator and RacketProxy.06-Unity-ulink-multiplayer-authoritative-physics-server-tutorial
  2. We will now focus our attention to the RacketCreator prefab, since it is the object on the server that will contain the true state of the rackets with which the server will base it’s physics calculations, the Owner and the Proxy motions will be approximated estimation of the Creator motion that will take care of latency with interpolation thanks to uLinkSmoothRigidbodyImproved script.
  3. Select the RacketCreator prefab. We will have physics collisions calculated by the server, so we need to make it a physic object : Add a Rigidbody component to the RacketCreator prefab ( Component->Physics->Rigidbody ). Set the Angular Drag option to 0. The Interpolate setting of the component must be set to Interpolation and you must freeze rotations on X,Y and Z axis. 07-Unity-ulink-multiplayer-authoritative-physics-server-tutorial
  4. We will need now to make the RacketCreator prefab a networked object capable to share its transform component with the Owner and the Proxy. We will need to add two uLink components to make this happen. First add a uLink NetworkView  ( Component-> uLink Basics –> Network View ) .
  5. Add the second required commponent : uLinkSmoothRigidbodyImproved  utlity script to RacketCreator ( Component->uLink Utilities->Smooth Rigidbody Improved ).
  6. Drag and Drop the uLink Smooth Rigidbody Improved (Script) title inside the ULink NetworkView Observed property :08-Unity-ulink-multiplayer-authoritative-physics-server-tutorial

Proxy and Owner prefabs copy

Our RacketCreator is almost finished, it lacks only the component that will manage user’s inputs requests. Since the actual configuration, without the input scripts, it’s the common shared configuration to allow correct networking synchronization between the Creator, Owner and Proxy prefabs you can copy the RacketCreator inside the RacketOwner and RacketProxy prefabs. Follow the next unity multiplayer tutorial step :

  1. Drag and Drop the RacketCreator prefab into the RacketOwner and RacketProxy prefabs, press the Replace option button if prompted.09-Unity-ulink-multiplayer-authoritative-physics-server-tutorial

So our three prefabs should share the same components configuration : Transform, Cube, Renderer, Collider, Rigidbody, ULink Network View, uLink Smooth Rigidbody Improved. In the next step of this Unity multiplayer tutorial with physics calculations on server we will add the input management components.

Leave a Comment