SynicSugar is Unity High-Level Network Library with EpicOnlineServices.
The concept is the syntax sugar of netcode. You can implement matchmaking, host migration, RPC and other basic functions for online game with SynicSugar.
There is no charge for use and no CCU limits or server management thanks to EpicGames.
Almost SynicSugar APIs are zero-allocation in Runtime, so the process is sonic. SynicSugar will be optimized for small-party game not covered by Mirror.
For more details, visit https://skeyll.github.io/SynicSugar/.
- Mesh topology with max 64 peers
- No Use Cost and No CCU Limit
- High-level APIs for mobile and small-party games (MatchMaking, Large-packet, PushToTalk, and Offlinemode...)
- Full support for Host-migration and Re-connection by library
- Almost all RPC processes are zero-allocation
- Free VoiceChat (Max16peers)
- Cross-platform connection
(Windows / Linux / macOS
Android / iOS
Nintendo Switch / Xbox One / Xbox Series X / PlayStation 4 / PlayStation 5)
using SynicSugar.P2P;
using UnityEngine;
[NetworkPlayer(true)]
public partial class Player {
//Sync every 1000ms(default)
[SyncVar] public int Hp;
//Sync every 3000ms
[SyncVar(3000)] Skill skill;
[Synic(0)] public string name;
[Synic(0)] public string item;
[Synic(1)] public Vector3 pos;
//To sync, the local Player just calls the owner's instance's RPC from Button or other methods.
[Rpc]
public void Attack(int damage){
Hp -= damage;
}
[TargetRpc]
public void GreetTarget(UserId id, string message){
Debug.log(message);
}
[Rpc]
public void Heal(HealInfo info){
Debug.log($"{OwnerUserId} heal {info.target} {info.amount}");
}
public void SyncBasisStatus(){
//Sync the Variables that have Synic(0) attribute at once.
ConnectHub.Instance.SyncSynic(p2pInfo.Instance.LastDisconnectedUsersId, 0);
}
}
- Unity 21.3 or 22.x
- UniTask
- MemoryPack
- eos_plugin_for_unity
- Mono.Cecil
SynicSugar generates sync processes using Roslyn SourceGenerator and inserts these codes into your project using Mono.Cecil. These operations are automatically performed at compile based on your network attributes. What we need to sync game is just adding network attributes.
The dependencies are for easily and performance. EOSSDK is not thread-safe, so cannot use async/await or task. However, UniTask runs everything on Unity's main thread and the perform of Unitask better than standard async/await. MemoryPack is the fastest serializer available in C#. Since SynicSugar is not synchronized with the server, we can freely choose a Serializer without having to consider compatibility.
In SynicSugar, User uses DeviceID of EOS's Connect Interface to log in EOS as an anonymous user.
For matchmaking, SynicSugar use Lobby Interface.
Host user creates lobbies for 2-64 players and Guest user seraches Lobby based on custom attributes you add. After the host closes the lobby manually or the lobby fills up with a specified number of players and the lobby is closed automatically, starts to preparation p2p connection. Host generates a random SocketID and adds the strings to Lobby attribute. Users use this One-time SocketID and UserId of EOS for actual connection.
Also, at this time, the LobbyID is saved in a specified location. Once the lobby is closed, only users who know the LobbyID can join the Lobby.
In SynicSugar, all connections continue even if the host drops out. The lobby host-migration occurs automatically. Reconnection can be done easily by calling some APIs. We add the "Synic" attribute to variables essential for restart, enabling safe data restoration for reconnecting players without the risk of direct overwriting as a form of cheating.
While there are plans to add account linking, TitleStorage, and PlayerStorage in the future, these features are not yet implemented. There are no plans to add Easy Anti-Cheat. Load map is here.
The first is to import SynicSugar and dependent libraries.
You can get SynicSugar from OpenUPM or SynicSugar/Release's unitypackage.
.unitypackage contains Mono.Cecil and System.Runtime.CompilerServices.Unsafe.dll for MemoryPack and, in addition to SynicSugar. Therefore, you can skip some processes, but it is more convenient to download via OpenUPM for version control.
- Rigister some package with OpenUPM
In your unity project, select Edit/ProjectSetting/PackageManager. Then, register SynicSugar.
Name: OpenUPM
URL: https://package.openupm.com
Scope(s):
For OpenUPM
- net.skeyll.synicsugar
For unitypackage
- com.cysharp.unitask
- com.playeveryware.eos
- com.cysharp.memorypack
- Install SynicSugar and dependecies
These packages can be imported from Window/PackageManager/MyRegistries. Importing SynicSugar will automatically import the other required librarys. If uses synicsugar.unitypackage, import other three packages.
If you are using another version in your project, that one will probably work. However, SynicSugar has been developed using the following:
- Epic Online Services Plugin for Unity: 3.3.3
- UniTask: 2.5.5
- MemoryPack: 1.10.0
- Import the rest (Skip if downloading as unitypackage.)
Import what is not in OpenUPM.
- Mono.Cecil
Enter com.unity.nuget.mono-cecil in Edit/ProjectSetting/PackageManager/+/Add package from git URL.
- System.Runtime.CompilerServices.Unsafe
MemoryPack need System.Runtime.CompilerServices.Unsafe.dll. You can get this dll from Download package in https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/6.0.0 . Since this contains DLLs for multiple environments, only import packages for Unity. Unzip the downloaded file and drag and drop lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll into your project. You can also get this DLL from this repo
Please check the eos document or the plugin page. SynicSugar doesn't need EOS store brand for mainly API now. Just register and can develop online games.
About app credential, you can use Peer2Peer as ClientPolicy. The minimum is as follows.
Ponolf is a quiz-based Imposter game. It supports 2-12 players and submit user drawn image as large packet. It also implements Host-Migration and re-connection. Ponolf supports cross-play between PC, Android, and iOS platforms.
License is under the MIT.
SynicSugar's concept is an easy online game development for everyone. Therefore, the development is also based on this policy. We can create online game for up to 64 people supported by EOS, but the main is small-party(2-16) game. If you want to create MMO, Survival Game and Party Game, you should use Mirror.
The roadmap is here. For the time being, add a basic function for online-game and improve the performance. If you need any necessary functions, please post it to Github Issue or give a pull request. Great thanks for all contributions!