Unity basic knowledge learning seven, frame synchronization source code learning

foreword

Before learning the source code of the frame synchronization framework, go through the basics: Unity basic learning six, network synchronization_u013617851's blog-CSDN blog

Video address: Frame Synchronization Tutorial [Collection]_哔哩哔哩_bilibili

github address: GitHub - JiepengTan/Lockstep-Tutorial: Frame Synchronization Tutorial

1. ServeraLifeCircle server

The server-side ServerLauncher.Main() startup entry:

 The server server receives the agreement and enters the Dispatch() distribution function:

2. new ClientLifeCycle client

Start and initialize Awake:

 

 Start and initialize Start:

 

Network protocol received: 

 

Unity script Update() function, and the update of frame synchronization real _Update() frame: 

 

3. How to start the server

3.1 Create a new dll project in the code directory

 

 3.2 Add LockstepEngine and SimpleServer solutions

 

3.3 Add a reference to SimpleServer

 

 

 3.4 Fix repeated error reporting for AssemblyInfo.cs features

 By the way in the configuration file SimpleServer.csproj

</PropertyGroup>

Add a line <GenerateAssemblyInfo>false</GenerateAssemblyInfo>

 Then open the XXXXXXXXXXXX.AssemblyInfo.cs file that was opened with the error report, open it with the resource manager, and delete it.

Re-right-click SimpleServer to clean up, and right-click to compile.

3.4 Install the .Net environment started by the server

Download .NET Core 2.2 SDK (v2.2.207) - Windows x64 Installer

3.5 Start SimpleServer and game client 

 The XXXX.exe on the desktop and the Unity editor start at the same time, and then the game will start: (Only start one, it will enter the waiting)

4. new Replay ClientMode and Debug (replay function, client mode, Debug)

4.1 Playback function initialization

 4.2 Update of playback function

4.3 Client Mode Initialization

 4.4 Client schema update and input

 4.5 Debug

5. RollBackFramework predicts rollback

6. Difficulties in frame synchronization frame design

6.1 Multi-platform

Bridge mode

Bridge Mode | Rookie Tutorial

Theoretical approach: use bridge mode + abstract factory

 Actual approach:

6.2 Multiple instances

For example, when you play Overwatch, after you die in battle, play the replay. The content in this replay must be parallel to the current content. It is necessary to ensure that the command operations in the playback cannot pollute the data of the current main content. This requires the frame synchronization system to support multiple instances.

  1. Do not use static variables unless they are const, or data used as const.
  2. Do not use singleton mode, do not use static static services, only const type services can be used.

6.3 View layer processing Config

The relationship between View and Entity

 Because both the client and the server are required to read the same configuration file Config, such as the configuration of the attack interval. (How do you feel that it is better to generate json directly with excel)

6.4 Data backup and restoration

6.5 Forecast

6.6 Debug

Guess you like

Origin blog.csdn.net/u013617851/article/details/123009965