Easy Multiplayer Physics (input Sync)

The easiest way (in my humble opinion) to add physics interactions in multiplayer, is to use Input Synchronizing. The most popular alternative is Client Side Prediction (CSP). Both have their pros and cons.

Guide going over implementing Input Synchronization with PurrNet

Input Sync VS Client Side Prediction

Client Side Prediction

โœ”๏ธ Instant response for players โœ”๏ธ Easy to cheat proof โŒ Difficult logic and hard to work with

Input Sync

โœ”๏ธ Easy workflow (nearly as easy as single player code) โœ”๏ธ Easy to cheat proof โŒ Sensitive to ping

Keep in mind, that even though it won't actually be as instant as something running locally, you can still smoke and mirrorarrow-up-right it to make it feel instant locally, by polishing to your game. This can be done with animations handled locally for example.

Why can't we just do physics for each client?

If the physics in your game does not interact between players, then you can do that just fine. However, if you want interactions between players, there has to be a single point of truth.

This is why various techniques has to be used in order to properly network physics interactions. They all come with their pros and cons, and in the end, it's all about you picking something suitable for your game!

How does it work

The idea and execution is very simple. Essentially it's fully a server auth simulation, that is conveyed to clients using the Network Transform.

Essentially: The client sends only it's input and intentions to the server, and the server does the actual action locally, and thus the server becomes the single point of truth for the whole game. This is what makes it cheat proof, and also able to handle physics interactions (because they are all simulated in one place)

Simple Example

This is essentially the example code shown from the video, with comments added to explain what is going on.

Last updated