SyncInput
Last updated
Last updated
The SyncInput sync types is good for owner authorized input synchronization with server authorized gameplay. This might sounds advanced, but is actually very simple!
The idea is: The server is responsible for all gameplay, and simply the necessary input is sent from client to server and from there the server will use it.
This is easy enough to do by utilizing RPC's, but can become non-performant quite easily by utilizing too many unnecessary input calls and too much data utilized. So PurrNet luckily provides a super easy to use module for this!
There are really only a few good ways of going about player on player interactions in Multiplayer. 1. - Difficult to work with and understand, but most responsive outcome 2. Input Synchronization - Easy to work with, but ping = input delay
Essentially the big strength of Input Synchronization is the workflow. It's extremely easy to understand and get working, given that all the game logic just has to run on the server and be conveyed to the clients. That's the whole idea. This is utilized in games such as:
Gang Beasts
Totally Accurate Battle Simulator (TABS) Multiplayer
Human: Fall Flat
Stick Fight: The Game
SyncInput<T>
takes any unmanaged or IEquatable type, meaning that you can not only use simple types, but also custom structs or classes as long as they can be compared with the equatable setup.
Other than just sending input from client to server, is also allows the case of host input to also have a simulated delay. The delay will cause the host to experience a similar experience to what clients do, in order to improve overall fairness.
This can be easily adjusted in editor, or during creation of the SyncInput. This is defined in ms (ping):
This can also easily be adjusted dynamically, if for example you'd want to match clients avg. ping. You can set it easily on the server/host by doing:
This setup requires a Rigidbody, a collider and a network transform component with owner auth toggled off. This will give you players that can collider cleanly using physics!