Creating a testbed
Before we create our rewinding system, we'll need a demo game to build off. For this one, we'll create a simple first person shooter (there is a pre-made first person controller asset included with Unity). Players can click to shoot, which will deal with 10 damages to the target. After receiving 100 or more damages, the player is disconnected from the match.
First, we'll start on an empty project. Import the Character Controller package (Assets | Import Package | Character Controller). This includes a first person character controller prefab (Standard Assets | Character Controllers | First Person Controller).
Drag this prefab into your scene. Additionally, create a plane for the character to stand on (make sure it's big enough for several players to run around).
The first thing we'll do is create a script for our networked player. For the sake of the demonstration we'll use a very simple method of interpolation.
Firstly, the base script. We only need three functions here:...