gaozhou / DelayNoMoreUnity

A Multiplayer Platformer game demo on websocket+UDP peer-to-peer with delayed-input Rollback Netcode inspired by GGPO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What's this project?

It's a Unity version of DelayNoMore, a Multiplayer Platformer game demo on websocket with delayed-input Rollback Netcode inspired by GGPO -- but with the backend also rebuilt in C#.

(battle between 4g Android v.s. Wifi Android via internet while UDP peer-to-peer holepunch failed, input delay = 2 frames i.e. ~32ms, the following GIF is converted from this video, please also checkout these older version videos, this dedicated slope dynamics video and this dedicated multi-enemy-head-walk video)

basic_ops

(demo for freezer buff since v1.2.7, original video here)

freezer_buff

Notable Features (by far, would add more in the future)

  • Automatically correction for "slow ticker", especially "active slow ticker" which is well-known to be a headache for input synchronization
  • Peer-to-peer UDP holepunching whenever possible, and will fallback to use the backend as a UDP relay/tunnel if holepunching failed for any participant (kindly note that UDP is always used along side with WebSocket, where the latter is a golden source of frame info)
  • Frame logging toggle for both frontend & backend (i.e. backend/Battle/Room.frameLogEnabled), useful for debugging out of sync entities when developing new features -- however, if you updated the battle dynamics and found certain introduced out-of-sync spots difficult to fix, please consider turning to backend-dynamics and broadcast reference-render-frames regularly, the original Golang version backend is a good reference for implementing backend-dynamics
  • Rollback compatible NPC patrolling and vision reaction
  • Rollback compatible static and dynamic traps, including a WYSIWYG notation support in Tiled editor (since v1.1.4)
  • Rollback compatible monodirectional platform which also supports slip-down operation
  • Simple slope dynamics
  • Standing and walking on multiple enemy-heads

(a typical framelog comparison from 2 peers)

framelog_comp

(where to find framelog files)

framelog_location

How does it work to synchronize across multiple players?

(how input delay roughly works)

input_delay_intro

(how rollback-and-chase in this project roughly works)

server_clients

rollback_and_chase_intro

(though using C# for both backend & frontend now, the idea to avoid floating err remains the same as shown below) floating_point_accumulation_err

1. Building & running

1.1 Tools to install

Backend

proj-root/backend> dotnet run

Frontend

Open OfflineScene to try out basic operations.

Open LoginScene after launching the backend to try out multiplayer mode. Available test accounts are listed in DevEnvResources.sqlite. The steps are very similar to that of DelayNoMore CocosCreator version.

Unit test

Referencing this document from Microsoft by far.

2. Thanks

3. Changing endpoints of UnityHub download and changing its http(s) proxy

Kindly note that the proxy setting is not very helpful here when download is slow (alternatively, sometimes the download is just timed out due to DNS issue, you might also wanna have a try on changing DNS only), changing the endpoints from https to http is critical.

changing_unity_hub_http

References

4. How to properly measure input-prediction performance in a reproducible manner?

It's always non-trivial to mock fluctuating network behaviours, and in this game we might be interested in testing the performance of different input-prediction algorithms, therefore we'd like to mock DETERMINISTIC inputs for a single player including

  • a) the initial map setup (from tmx), and
  • b) the initial character choices of all players, and
  • c) received RoomDownsyncFrames, InputDownsyncFrames (from websocket) and InputUpsyncFrames (from UDP peers) at EXACTLY THE SAME TIMINGS for different runs of different algorithms in test.

The first two, i.e. a) & b) are easy to mock and c) is possible by mocking OnlineMapController.pollAndHandleWsRecvBuffer and OnlineMapController.pollAndHandleUdpRecvBuffer.

I should've provided an example of this type of test for the alleged good performance of my algorithm, especially for

FAQ

Please refer to FAQ.md.

About

A Multiplayer Platformer game demo on websocket+UDP peer-to-peer with delayed-input Rollback Netcode inspired by GGPO


Languages

Language:C# 90.8%Language:ShaderLab 5.4%Language:HLSL 3.3%Language:HTML 0.3%Language:Smalltalk 0.1%Language:Shell 0.1%