Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ For an in-depth overview of the project's architecture please check out our [ARC
- Once path-plan is finished, server representation of entity starts updating its NetworkedTransform at 30fps. Graphics is on a separate GO and is connected to the networked GO via a spring, to smooth out small corrections.
- Graphics GO never passes the simulation GO; if it catches up to the sim due to a network delay, the user will see a hitch.

### Transports

Boss Room provides players with two ways to connect to a server.

- IP based: The clients connect directy to a host via IP address. This will only work if both are in the same local are network or if the host forwards ports.
- Relay Based: The clients and the host connect to a relay server with a room key and run all traffic over this relay server.

To allow for both of these options to be chosen at runtime we created `TransportPicker`. `Transport` picker allows to chose a ip based and a relay based transport and will hook up the game UI to use those transports. The transport field in the `NetworkManager` will be ignored. Currently we support the following transports:
- **UNet(IP):** UNet is the default MLAPI transport and the default IP transport for Boss Room.
- **LiteNetLib(IP):** We use LiteNetLib in Boss Room because it has a built in way to simulate latency which is useful for spotting networking issues early during development.
- **Photon Realtime (Relay):** Photon Realtime is a relay transport using the [Photon Realtime Service](https://www.photonengine.com/Realtime).

To add new transport in the project parts of `GameNetPortal` and `ClientGameNetPortal` (transport switches) need to be extended.

### Navigation System

#### Building a navigation mesh
Expand Down
35 changes: 17 additions & 18 deletions Assets/BossRoom/Prefabs/NetworkingManager.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ MonoBehaviour:
m_NickName:
m_RoomName:
m_MaxPlayers: 16
m_ChannelIdCodesStartRange: 0
m_ChannelIdCodesStartRange: 130
m_AttachSupportLogger: 0
m_BatchMode: 1
m_SendQueueBatchSize: 4096
m_BatchedTransportEventCode: 129
m_KickEventCode: 130
--- !u!1 &3591499506183471245
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -68,7 +67,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &5355783542964773244
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -115,8 +114,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 5436007408952557925}
- component: {fileID: 5436007408952557924}
- component: {fileID: 1359040526}
- component: {fileID: 5436007408952557924}
m_Layer: 0
m_Name: NetworkingManager
m_TagString: Untagged
Expand All @@ -141,6 +140,20 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1359040526
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5436007408952557947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0c0e18361257a9f409d6064bac74e732, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IpHostTransport: {fileID: 7898291372908163337}
m_RelayTransport: {fileID: 409269882}
--- !u!114 &5436007408952557924
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -225,20 +238,6 @@ MonoBehaviour:
type: {class: NullableBoolSerializable, ns: MLAPI.Configuration, asm: Unity.Multiplayer.MLAPI.Runtime}
data:
Value: 1897319656204293034
--- !u!114 &1359040526
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5436007408952557947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0c0e18361257a9f409d6064bac74e732, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IpHostTransport: {fileID: 7898291372908163337}
m_RelayTransport: {fileID: 409269882}
--- !u!1 &6889060209805043266
GameObject:
m_ObjectHideFlags: 0
Expand Down
4 changes: 2 additions & 2 deletions Assets/BossRoom/Scripts/Client/BossRoom.Client.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"Unity.Multiplayer.MLAPI.Runtime",
"BossRoom.Shared",
"Cinemachine",
"LiteNEt MLAPI Transport",
"Photon Realtime MLAPI Transport"
"Photon Realtime MLAPI Transport",
"LiteNetLib MLAPI Transport"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
5 changes: 4 additions & 1 deletion Assets/BossRoom/Scripts/Client/Net/ClientGameNetPortal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using UnityEngine.SceneManagement;
using MLAPI;
using MLAPI.Transports;
using MLAPI.Transports.LiteNetLib;
using MLAPI.Transports.PhotonRealtime;
using MLAPI.Transports.UNET;

Expand Down Expand Up @@ -92,9 +93,11 @@ public static void StartClient(GameNetPortal portal, string ipaddress, int port)
{
//DMW_NOTE: non-portable. We need to be updated when moving to UTP transport.
var chosenTransport = NetworkManager.Singleton.gameObject.GetComponent<TransportPicker>().IpHostTransport;
NetworkManager.Singleton.NetworkConfig.NetworkTransport = chosenTransport;

switch (chosenTransport)
{
case LiteNetLibTransport.LiteNetLibTransport liteNetLibTransport:
case LiteNetLibTransport liteNetLibTransport:
liteNetLibTransport.Address = ipaddress;
liteNetLibTransport.Port = (ushort)port;
break;
Expand Down
4 changes: 2 additions & 2 deletions Assets/BossRoom/Scripts/Shared/BossRoom.Shared.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"rootNamespace": "",
"references": [
"Unity.Multiplayer.MLAPI.Runtime",
"LiteNEt MLAPI Transport",
"Photon Realtime MLAPI Transport"
"Photon Realtime MLAPI Transport",
"LiteNetLib MLAPI Transport"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using UnityEngine.UI;
using MLAPI;
using MLAPI.Transports;
using MLAPI.Transports.LiteNetLib;
using MLAPI.Transports.PhotonRealtime;
using UnityEngine.Assertions;

Expand All @@ -27,7 +28,7 @@ void Update()
{
// adding this preprocessor directive check since LiteNetLib only injects latency in #DEBUG
#if DEBUG
case LiteNetLibTransport.LiteNetLibTransport liteNetLibTransport:
case LiteNetLibTransport liteNetLibTransport:
m_ArtificialLatencyEnabled = liteNetLibTransport.SimulatePacketLossChance > 0 ||
liteNetLibTransport.SimulateMinLatency > 0 ||
liteNetLibTransport.SimulateMaxLatency > 0;
Expand Down
4 changes: 2 additions & 2 deletions Assets/BossRoom/Scripts/Shared/Net/GameNetPortal.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Net.Sockets;
using MLAPI.Serialization.Pooled;
using MLAPI.Transports;
using MLAPI;
using MLAPI.Transports.LiteNetLib;
using MLAPI.Transports.PhotonRealtime;
using UnityEngine;

Expand Down Expand Up @@ -167,7 +167,7 @@ public void StartHost(string ipaddress, int port)
//DMW_NOTE: non-portable. We need to be updated when moving to UTP transport.
switch (chosenTransport)
{
case LiteNetLibTransport.LiteNetLibTransport liteNetLibTransport:
case LiteNetLibTransport liteNetLibTransport:
liteNetLibTransport.Address = ipaddress;
liteNetLibTransport.Port = (ushort)port;
break;
Expand Down
7 changes: 2 additions & 5 deletions Assets/BossRoom/Scripts/Shared/TransportPicker.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BossRoom;
using MLAPI;
using MLAPI.Transports;
using MLAPI.Transports.LiteNetLib;
using MLAPI.Transports.PhotonRealtime;
using MLAPI.Transports.UNET;
using UnityEngine;
Expand Down Expand Up @@ -32,7 +29,7 @@ public class TransportPicker : MonoBehaviour

void OnValidate()
{
Assert.IsTrue(m_IpHostTransport == null || (m_IpHostTransport as UNetTransport || m_IpHostTransport as LiteNetLibTransport.LiteNetLibTransport),
Assert.IsTrue(m_IpHostTransport == null || (m_IpHostTransport as UNetTransport || m_IpHostTransport as LiteNetLibTransport),
"IpHost transport must be either Unet or LiteNetLib transport.");

Assert.IsTrue(m_RelayTransport == null || (m_RelayTransport as PhotonRealtimeTransport), "" +
Expand Down
5 changes: 0 additions & 5 deletions Packages/com.unity.multiplayer.transport.litenet/CHANGELOG.md

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions Packages/com.unity.multiplayer.transport.litenet/LICENSE.md

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion Packages/com.unity.multiplayer.transport.litenet/README.md

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions Packages/com.unity.multiplayer.transport.litenet/Runtime.meta

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading