Contents - Quick Links
- 1Unity multiplayer tutorial, physics calculations on server
- 2Creating the pong field
- 3Creator and Proxy prefab and adding components
- 4Creating and adding the Inputs components to enable player control
- 5Creating the Server and the Client connection logic
- 6Implementing the ball
- 7Building the game .exe and Unity full project download
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 :
- 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.
- 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.
- 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.
- 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 ) .
- Add the second required commponent : uLinkSmoothRigidbodyImproved utlity script to RacketCreator ( Component->uLink Utilities->Smooth Rigidbody Improved ).
- Drag and Drop the uLink Smooth Rigidbody Improved (Script) title inside the ULink NetworkView Observed property :
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 :
- Drag and Drop the RacketCreator prefab into the RacketOwner and RacketProxy prefabs, press the Replace option button if prompted.
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.