新增FishNet文档
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
---
|
||||
description: >-
|
||||
Manager components are generally only added once per NetworkManager and play a
|
||||
vital role on configuring your project.
|
||||
---
|
||||
|
||||
# Managers
|
||||
|
||||
The [NetworkManager](network-manager.md) will automatically add the needed manager components to itself at run-time, if they aren't already added. You can add them yourself to customize their settings in the editor. 
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
---
|
||||
description: The ClientManager provides settings unique to clients.
|
||||
---
|
||||
|
||||
# ClientManager
|
||||
|
||||
## Description <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
The **ClientManager** is FishNet's primary orchestrator for client-side networking, managing connections, state, event handling, and all data flow between the local client and the server.
|
||||
|
||||
It maintains a reference to the network connection of the local client, `Connection`, keeps track of all known networked objects on the client through `ClientObjects`, as well as optionally tracks all currently connected clients (when [server ID sharing](server-manager.md#share-ids) is enabled), using a dictionary of client connections. The ClientManager also has many useful events, such as when a client is authenticated and when the local client or a remote client changes their network state. It also is used for sending [broadcasts](../../../guides/features/network-communication/broadcasts.md) to the server.
|
||||
|
||||
When enabled, this component will also timeout the client from the server if the server doesn't respond after a set time.
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods and events [here](https://fish-networking.com/FishNet/api/api/FishNet.Managing.Client.ClientManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left" data-full-width="false"><figure><img src="../../../.gitbook/assets/client-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Remote Server Timeout**
|
||||
|
||||
> This decides if the client should disconnect when the server seems unresponsive. This feature can be set to **disabled**, work in **development** and releases, or only **releases**.
|
||||
>
|
||||
> * **Timeout** is how long the server must be unresponsive before they are kicked.
|
||||
|
||||
### :gear: **Change Frame Rate**
|
||||
|
||||
> While enabled, this will change the frame rate limitation when acting as client only.
|
||||
>
|
||||
> * **Frame Rate** is the frame rate to use while only the client is active. There is also a setting for client frame rate on the [ServerManager](server-manager.md). When both client and server are active the higher of the two frame rates will be used.
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
---
|
||||
description: >-
|
||||
The DebugManager helps you debug various networking functions when in the
|
||||
Unity Editor or Development builds.
|
||||
---
|
||||
|
||||
# DebugManager
|
||||
|
||||
## Description <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
The **Debug Manager** component can be used to gain extra information and temporarily tweak certain networking aspects to assist in debugging errors in your game. For example, if you are running into Scene ID errors you can enable the Detailed Writing of Scene Objects to know the object names instead of just IDs. These settings often come at the cost of a little more bandwidth used and are only enabled in the Editor and Development builds of your game.
|
||||
|
||||
{% hint style="warning" %}
|
||||
Note that having a DebugManager with some of its settings enabled can cause issues when connecting non-development builds to development ones (including the editor).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left"><figure><img src="../../../.gitbook/assets/debug-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Scene Objects**
|
||||
|
||||
> This adds information about scene objects instead of just sending IDs. You can use this when debugging missing sceneId / spawn-related issues.
|
||||
|
||||
### :gear: **RPC Lengths**
|
||||
|
||||
> This will validate written versus read length of RPCs when enabled. Use in development to detect serialization mismatches in RPCs (written length vs read length).
|
||||
|
||||
### :gear: **ObserversRpcs**
|
||||
|
||||
> This disables ObserverRpc links.
|
||||
|
||||
### :gear: **TargetRpcs**
|
||||
|
||||
> This disables TargetRpc links.
|
||||
|
||||
### :gear: **ServerRpcs**
|
||||
|
||||
> This disables ServerRpcs links.
|
||||
|
||||
### :gear: **ReplicateRpcs**
|
||||
|
||||
> This disables ReplicateRpc links.
|
||||
|
||||
### :gear: **ReconcileRpcs**
|
||||
|
||||
> This disables ReconcileRpc links.
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
---
|
||||
description: >-
|
||||
The NetworkManager is an essential component for running the client and
|
||||
server. It acts as a bridge between core components and configuring your
|
||||
network.
|
||||
---
|
||||
|
||||
# NetworkManager
|
||||
|
||||
## Description
|
||||
|
||||
The **NetworkManager** is the central component of FishNet that manages the networking lifecycle, including establishing connections, hosting sessions, and handling client-server communication. Although this component manages the network, it should not itself be a networked object, and must not contain a [Network Object](../network-object.md) component on the same object, or as a parent or child of it. Additionally, the Network Manager can be used to register components and access them directly from it. This can be useful for other manager like scripts.
|
||||
|
||||
The Network Manager utilizes several sub-manager components, which it will add at runtime if they do not already exist on the object.
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods and events [here](https://fish-networking.com/FishNet/api/api/FishNet.Managing.NetworkManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left"><figure><img src="../../../.gitbook/assets/network-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Run In Background**
|
||||
|
||||
> This allows the application to run in the background when true. Running in the background is often essential for clients, and especially for the server.
|
||||
|
||||
### :gear: **Don't Destroy On Load**
|
||||
|
||||
> This will ensure the Network Manager persist between scene changes. If you are using only one Network Manager it's best to leave this true.
|
||||
|
||||
### :gear: **Persistence**
|
||||
|
||||
> This option specifies how to behave when multiple NetworkManagers exist in your game.
|
||||
|
||||
### :gear: **Logging**
|
||||
|
||||
> This lets you specify what actions to log for builds, editor, and headless mode. When the field is not populated, the default logging settings are used. To make a custom logging settings open your create menu and choose: **Tools > Fish-Networking > Logging > Logging Configuration.**
|
||||
|
||||
### :gear: **Spawnable Prefabs**
|
||||
|
||||
> This option dictates which prefabs collection to use for networked objects. By default this field is automatically set to DefaultPrefabObjects for any saved scene; you can however make your own PrefabObjects class with customized rules and applications.
|
||||
|
||||
### :gear: **Object Pool**
|
||||
|
||||
> Which object pooling script to use. When not set, DefaultObjectPool is added automatically at run-time. You may inherit from ObjectPool to create your own.
|
||||
|
||||
### :gear: **Refresh Default Prefabs**
|
||||
|
||||
> While true, this will refresh the DefaultPrefabCollection every time play mode is entered. This is generally not needed to be enabled, but can be useful if your prefab collection is regularly becoming corrupted through symlinks.
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
---
|
||||
description: >-
|
||||
The ObserverManager assists in controlling what network objects each client
|
||||
may see.
|
||||
---
|
||||
|
||||
# ObserverManager
|
||||
|
||||
## Description <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
**ObserverManager** is used to globally customize the observer system. Observer conditions within the ObserverManager will be automatically added to [NetworkObjects](../../../../guides/features/networked-gameobjects-and-scripts/networkobjects/), unless the [NetworkObserver](../../network-observer.md) component is set to ignore the manager.
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods and events [here](https://fish-networking.com/FishNet/api/api/FishNet.Managing.Observing.ObserverManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left"><figure><img src="../../../../.gitbook/assets/observer-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Update Host Visibility**
|
||||
|
||||
> This will hide renderers on networked objects which are hidden to host client. When false, all networked objects will be visible to the host client even if these objects would normally be despawned for the client.
|
||||
|
||||
### :gear: **Maximum Timed Observers Duration**
|
||||
|
||||
> The maximum duration that the server will take to update timed observer conditions as server load increases. Lower values will result in timed conditions being checked quicker at the cost of performance.
|
||||
|
||||
### :gear: **Default Conditions**
|
||||
|
||||
> These are [Observer Conditions](../../../scriptableobjects/observerconditions/) which will be added to all NetworkObjects by default.
|
||||
>
|
||||
> Almost all games should utilize at least the [Scene Observer Condition](../../../scriptableobjects/observerconditions/scenecondition.md).
|
||||
|
||||
### :gear: Use **Level of Detail**
|
||||
|
||||
> This will enable the [LOD system](../../../../guides/features/level-of-detail.md) and show the options for configuring it. It requires [FishNet Pro](../../../../guides/updating-fishnet/upgrading-to-fishnet-pro.md).
|
||||
|
||||
### :gear: Maximum Send Interval
|
||||
|
||||
> The upper limit for how long (in seconds) the system will wait between updates for objects in the furthest LOD bracket. If set to `5`, the most distant objects will only receive updates once every 5 seconds.
|
||||
|
||||
### :gear: Recalculation Duration
|
||||
|
||||
> This determines how quickly (in seconds) the server cycles through objects to update their current LOD status.
|
||||
>
|
||||
> This value scales automatically if the server's frame rate is capped. Lower values are generally more ideal to ensure objects transition between LOD brackets responsively.
|
||||
>
|
||||
> Use `SetLevelOfDetailRecalculationDuration(float duration)` if you want to adjust this value at run-time.
|
||||
|
||||
### :gear: **Level of Detail Distances**
|
||||
|
||||
> This is a list of distance thresholds. Each entry defines a "bracket" for synchronization frequency.
|
||||
>
|
||||
> _Example:_ If you have two distances set to `5` and `15`, FishNet will run with the following setup:
|
||||
>
|
||||
> * Near (< 5 units): Objects sync at the standard, full-speed interval.
|
||||
> * Mid (5 to 14.9 units): Objects sync at a reduced "mid-tier" frequency.
|
||||
> * Far (≥ 15 units): Objects sync at the maximum allowed delay.
|
||||
>
|
||||
> The system uses an **exponential scaling** method to determine how often updates are sent for each distance bracket. This ensures a smooth transition between high-frequency updates for nearby objects and low-frequency updates for distant ones.
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
---
|
||||
description: >-
|
||||
The HashGrid is the managing script for when using the Grid Observer
|
||||
Condition.
|
||||
---
|
||||
|
||||
# HashGrid
|
||||
|
||||
## Description
|
||||
|
||||
The **HashGrid** is required when using the [Grid Condition](../../network-observer.md). This component is responsible for managing the grid and providing information to grid objects. While grids are less accurate than using the [Distance Condition](../../../scriptableobjects/observerconditions/distancecondition.md) they do provide better performance. HashGrid must be placed on or beneath the [NetworkManager ](../network-manager.md)object.
|
||||
|
||||
## Settings
|
||||
|
||||
<div align="left"><figure><img src="../../../../.gitbook/assets/hash-grid-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Grid Axes**
|
||||
|
||||
> These are which axes to base the grid on. Whichever axis is excluded will not have it's values considered in calculations. For example, if you are developing a 2D game most likely only XY matters, so you would choose the XY axes.
|
||||
|
||||
### :gear: **Accuracy**
|
||||
|
||||
> This determines how close a client's [FirstObject](https://fish-networking.com/FishNet/api/api/FishNet.Connection.NetworkConnection.html#FishNet_Connection_NetworkConnection_FirstObject) must be (in Unity units) to be considered in range. Note that accuracy is not as precise as when using a [Distance Condition](../../../scriptableobjects/observerconditions/distancecondition.md).
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
---
|
||||
description: >-
|
||||
The PredictionManager provides states, callbacks, and settings to fine tuning
|
||||
prediction for your game type.
|
||||
---
|
||||
|
||||
# PredictionManager
|
||||
|
||||
## Description <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
The **PredictionManager** is a core component responsible for managing the prediction system, which allows clients to predict their own actions and then reconcile (correct) their state when authoritative updates are received from the server. It allows you to tweak various global prediction settings and get certain prediction callbacks.
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods and events [here](https://fish-networking.com/FishNet/api/api/FishNet.Managing.Predicting.PredictionManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left"><figure><img src="../../../.gitbook/assets/prediction-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: Create Local States
|
||||
|
||||
> When enabled this allows the client to create local reconcile states which means reconciles can be sent less frequently and provide data to use for reconciles when packets are lost.
|
||||
|
||||
### :gear: State **Interpolation**
|
||||
|
||||
> This is how many states to try and hold in a buffer before running them on clients. Larger values add resilience against network issues at the cost of running states later.
|
||||
|
||||
### :gear: State **Order**
|
||||
|
||||
> The order in which clients run states. **Future** favors performance and does not depend upon reconciles, while **Past** favors accuracy but clients must reconcile every tick.
|
||||
|
||||
### :gear: **Drop Excessive Replicates**
|
||||
|
||||
> Toggle the setting to true to drop excessive client replicates, helping prevent attacks but risking temporary desynchronization during connectivity issues. Set to false to store up to 3 seconds of replicates, processing multiple per tick for quicker cache clearing. This approach ensures all inputs are executed but could enable speed hacking. When false, replicated data is consumed more quickly if the cache limit is exceeded.
|
||||
|
||||
### :gear: Maximum Server Replicates
|
||||
|
||||
> This is shown when the **Drop Excessive Replicates** is enabled. This value indicates the maximum number of replicates which the server will cache from client before dropping old ones. Higher values will reduce the chance of dropped input when the client's connection is unstable, but will potentially add latency to the client's object both on the server and client. Generally, cached replicates will never significantly exceed Queued Inputs.
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
description: >-
|
||||
RollbackManager contains configurations and optimizations for how colliders
|
||||
are sent back in time when using lag compensation.
|
||||
---
|
||||
|
||||
# RollbackManager (Pro Feature)
|
||||
|
||||
## Description <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
The RollbackManager must be added and configured properly for lag compensation to function properly. Objects you wish to rollback must contain the[ ColliderRollback](../colliderrollback.md) script on them. You can learn more about using it on this page: [lag-compensation](../../../guides/features/lag-compensation/ "mention")
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods [here](https://fish-networking.com/FishNet/api/api/FishNet.Component.ColliderRollback.RollbackManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left"><figure><img src="../../../.gitbook/assets/rollback-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Bounding Box Layer**
|
||||
|
||||
> This is the layer to first test against before rolling back colliders. When a layer is specified a collider will be added to your [ColliderRollback](../colliderrollback.md) objects; because of this, be sure to use a layer which has no physics intersections and is not used for anything else.
|
||||
|
||||
### :gear: **Maximum Rollback Time**
|
||||
|
||||
> This is the maximum of seconds colliders may rollback. Using a value of 1f would allow colliders to rollback at most one second in the past, which is a very reasonable amount of time given typical player latencies are less than 100ms.
|
||||
|
||||
### :gear: **Interpolation**
|
||||
|
||||
> This is the amount of interpolation you are using on your [NetworkTransform](../network-transform.md) components. Or if you are using rigidbodies with prediction this would be the **interpolation** value on the smoothing component.
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
---
|
||||
description: >-
|
||||
The SceneManager handles networking scenes between the server and clients,
|
||||
including updating active scenes, addressable scenes, provide helpful
|
||||
callbacks, and more.
|
||||
---
|
||||
|
||||
# SceneManager
|
||||
|
||||
## Description <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
FishNet’s **SceneManager** provides robust, synchronized, and event-driven scene management for networked Unity games, ensuring all clients and the server remain in sync throughout complex scene operations. It is responsible for coordinating which scenes are loaded or unloaded across all clients and the server, ensuring synchronization and exposes many options for the loading of scenes. There are multiple guides that are worth reading about it: [scene-management](../../../guides/features/scene-management/ "mention")
|
||||
|
||||
The callbacks within the SceneManager are informative and quite useful, well worth looking into!
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods and events [here](https://fish-networking.com/FishNet/api/api/FishNet.Managing.Scened.SceneManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left"><figure><img src="../../../.gitbook/assets/scene-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Scene Processor**
|
||||
|
||||
> This determines how scene loads occur. When left empty the default scene processor is used. For more information on scene processing and addressables see [here.](../../../guides/features/scene-management/custom-scene-processors/addressables.md)
|
||||
|
||||
### :gear: **Light Probe Updating**
|
||||
|
||||
> This controls how light probes are updated after scenes are loaded.
|
||||
|
||||
### :gear: **Move Client Host Objects**
|
||||
|
||||
> When enabled this will move objects visible to the host client to a temporary scene rather than let them be destroyed when a scene is unloaded. Objects are then destroyed next tick by the host client. This ensures that server and client side callbacks will work properly on the moved objects.
|
||||
|
||||
### :gear: **Set Active Scene**
|
||||
|
||||
> This will allow the **SceneManager** to pick which scene to set as the active scene when loading and unloading scenes. By default global scenes are used, and if no global scenes then the clients single scene.
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
---
|
||||
description: >-
|
||||
The ServerManager handles validation of clients and a variety of settings only
|
||||
applicable to the server.
|
||||
---
|
||||
|
||||
# ServerManager
|
||||
|
||||
## Description <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
The **ServerManager** is a central component responsible for handling server-related data and actions. It maintains information and handles operations for server-side networked objects as well as tracking connected clients, both authenticated and unauthenticated. Additionally, it monitors client timeouts and disconnects unresponsive clients.
|
||||
|
||||
The **ServerManager** can be used directly to start and stop the FishNet server as well as monitor its state and send [broadcasts](../../../guides/features/network-communication/broadcasts.md) to the clients.
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods and events [here](https://fish-networking.com/FishNet/api/api/FishNet.Managing.Server.ServerManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left"><figure><img src="../../../.gitbook/assets/server-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **SyncType Rate**
|
||||
|
||||
> This is the default send rate for [SyncTypes](../../../guides/features/network-communication/synchronizing/). Setting it to 0 will send updates every tick. This value can be overridden for individual SyncTypes.
|
||||
|
||||
### :gear: **Spawn Packing**
|
||||
|
||||
> This determines how well transform properties will be packed[^1] when being sent in a spawn message. If transforms spawn marginally off reducing the packing may help.
|
||||
>
|
||||
> These can be edited for **Position**, **Rotation** and **Scale** independently.
|
||||
|
||||
### :gear: **Change Frame Rate**
|
||||
|
||||
> When enabled, this will change the frame rate limitation when acting as server only.
|
||||
>
|
||||
> * **Frame Rate** is the frame rate to use while only the server is active. There is also a setting for client frame rate on the [ClientManager](clientmanager.md). When both server and client are active the higher of the two frame rates will be used.
|
||||
|
||||
### :gear: **Start On Headless**
|
||||
|
||||
> When this is enabled, FishNet will automatically start the server when loaded on a server (headless) build.
|
||||
|
||||
### :gear: **Remote Client Timeout**
|
||||
|
||||
> This decides if the server should disconnect clients which seem unresponsive. This feature can be set to disabled, work in development and releases, or only releases.
|
||||
>
|
||||
> * **Timeout** is how long the client must be unresponsive before they are kicked.
|
||||
|
||||
### :gear: **Share Ids**
|
||||
|
||||
> While true, this enables clients to be aware of other clients in-game and objects owned by other clients. Objects owned by other clients are only known if they are available to the local client, such as through the observer system. Client Ids are not sensitive information but leaving this option enabled will use slightly additional bandwidth.
|
||||
|
||||
### :gear: **Authenticator**
|
||||
|
||||
> This is where you can specify which [authenticator](../utilities/authenticator.md) to use. When left empty clients may join the server without specialized authentication.
|
||||
|
||||
### :gear: **Allow Predicted Spawning**
|
||||
|
||||
> This option lets prefabs and scene objects be setup to use [Predicted Spawning](../../../guides/features/networked-gameobjects-and-scripts/spawning/predicted-spawning.md). You can use this setting to enable or disable predicted spawning without having to change the settings for every object. This value may also be set at runtime. If changing at runtime be certain to also change on the client; otherwise they could be kicked for trying to use a disabled feature.
|
||||
>
|
||||
> * **Reserved Object Ids** is the number of ObjectIds to reserve per client for predicted spawning. Clients will start out with the specified number of Ids and receive new ones as the server validates their predicted spawning requests. For example: if this value was set to 15 and a client with a 100ms ping sent 3 predicted spawns in one tick then they would have only 12 predicted spawns left to use until the server responded with 3 new Ids, which would be approximately 50ms later.
|
||||
|
||||
[^1]: compressed together to save bandwidth
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
description: >-
|
||||
The StatisticManager provides statics about Fish-Networking for a variety of
|
||||
tasks, including monitoring network traffic.
|
||||
---
|
||||
|
||||
# StatisticsManager
|
||||
|
||||
## Description <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
The **Statistics Manager** component is responsible for tracking and reporting network traffic statistics for your multiplayer game. Its **Network Traffic** can be used to gain basic information about how much network traffic your game is using. These values must be enabled for the [BandwidthDisplay](../utilities/bandwidthdisplay.md) component to function.
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods and events [here](https://fish-networking.com/FishNet/api/api/FishNet.Managing.Statistic.StatisticsManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left"><figure><img src="../../../.gitbook/assets/statistics-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Update Interval**
|
||||
|
||||
> This is how often network traffic related operations occur, such as invoking update events.
|
||||
|
||||
### :gear: **Update Client**
|
||||
|
||||
> This will invoke client traffic updates when enabled.
|
||||
|
||||
### :gear: **Update Server**
|
||||
|
||||
> This will invoke server traffic updates when enabled.
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
---
|
||||
description: The TimeManager handles and provides callbacks related to network timing.
|
||||
---
|
||||
|
||||
# TimeManager
|
||||
|
||||
## Description <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
The **TimeManager** component is responsible for managing network time and tick-based systems within the networking framework. It is central to keeping networked objects synchronized in time, handling ticks, timing conversions, physics step control, and providing hooks for network-related timing events in FishNet. It does this by managing how network timing is performed, either using fixed ticks or variable intervals and by providing precise timing for sending and receiving network data, ensuring synchronization between server and clients. It also controls the physics simulation mode (manual, automatic, or disabled) to maintain consistent simulation across the network.
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods and events [here](https://fish-networking.com/FishNet/api/api/FishNet.Managing.Timing.TimeManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings <a href="#server-and-host" id="server-and-host"></a>
|
||||
|
||||
<div align="left"><figure><img src="../../../.gitbook/assets/time-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Update Order**
|
||||
|
||||
> Controls when the TimeManager will invoke its version of Unity callbacks. BeforeTick would be a good option if you wanted to collect input in OnUpdate before the tick occurred.
|
||||
|
||||
### :gear: **Timing Type**
|
||||
|
||||
> Dictates when data is sent and read. When set to Tick data is only processed on frames which also tick. When Variable is selected data will be sent and read every frame, when available.
|
||||
|
||||
### :gear: **Allow Tick Dropping**
|
||||
|
||||
> Will let the client skip ticks when they occur several times over a single frame. This can be useful to prevent the client from running an increasing number of simulations per frame, resulting in more performance loss.
|
||||
|
||||
### :gear: **Maximum Frame Ticks**
|
||||
|
||||
> This is shown when **Allow Tick Dropping** is enabled. This value is the maximum number of ticks that can occur per frame before the client begins dropping ticks to recover performance.
|
||||
|
||||
### :gear: **Tick Rate**
|
||||
|
||||
> This is an average of how many times per second the TimeManager will invoke tick events, as well how often data may be sent or received.
|
||||
|
||||
### :gear: **Ping Interval**
|
||||
|
||||
> How often, in seconds, a user receives a ping update. A larger ping has a very small chance of server tick synchronization losing accuracy. These changes do not affect prediction.
|
||||
|
||||
### :gear: **Timing Interval**
|
||||
|
||||
> This is how many seconds between prediction timing updates. Lower values will result in marginally more accurate timings at the cost of bandwidth.
|
||||
|
||||
### :gear: **Physics Mode**
|
||||
|
||||
> The Physics Mode determines how physics are run. **Unity** will let the engine manage physics. **TimeManager** simulates physics on ticks. When using Client-Side Prediction you must use the **TimeManager** setting.
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
---
|
||||
description: >-
|
||||
The TransportManager handles talking to the transports as well sending,
|
||||
receiving, and even customizing packets on the fly.
|
||||
---
|
||||
|
||||
# TransportManager
|
||||
|
||||
## Description
|
||||
|
||||
The **TransportManager** in FishNet is a central component responsible for communicating with the underlying network transport to send and receive data. It acts as the bridge between FishNet’s networking system and the actual transport layer, enabling networked games to send/receive packets to and from clients and servers. There is also support for latency simulation for testing different network conditions.
|
||||
|
||||
With the TransportManager you can optionally utilize an intermediate layer to modify data before it’s sent or after it’s received (e.g., encryption, compression).
|
||||
|
||||
If you want to modify network data such as for encryption, or use any one of our number of transports, you will want to add this component to your [NetworkManager](../network-manager.md) game object.
|
||||
|
||||
{% hint style="success" %}
|
||||
Check out its API page for more specific methods and events [here](https://fish-networking.com/FishNet/api/api/FishNet.Managing.Transporting.TransportManager.html).
|
||||
{% endhint %}
|
||||
|
||||
## Settings
|
||||
|
||||
<div align="left"><figure><img src="../../../../.gitbook/assets/transport-manager-component.png" alt=""><figcaption><p>Default settings</p></figcaption></figure></div>
|
||||
|
||||
### :gear: **Transport**
|
||||
|
||||
> This field indicates which [transport](../../../../guides/high-level-overview/transports.md) to use. When left empty, the default transport ([Tugboat](../../../transports/tugboat.md)) is used, or the first transport manually added to the object which the TransportManager resides.
|
||||
|
||||
### :gear: **Intermediate Layer**
|
||||
|
||||
> This is used to specify a custom [intermediate layer](intermediatelayer.md) to use.
|
||||
|
||||
### :gear: Latency Simulator
|
||||
|
||||
> These settings allow you to simulate a variety of latency scenarios on any transport.
|
||||
>
|
||||
> * **Enabled:** Toggles the enabled state of the simulator.
|
||||
> * **Simulate Host:** When enabled, this will also simulate latency for host client.
|
||||
> * **Latency:** Is the amount of latency to simulate in milliseconds.
|
||||
> * **Unreliable:** Features only used for unreliable packets.
|
||||
> * **Out Of Order:** The percentage chance to send an out of order packet.
|
||||
> * **Packet Loss:** The chance to drop a packet.
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
---
|
||||
description: >-
|
||||
The IntermediateLayer is a pass-through for data in and out. This feature can
|
||||
be used to encrypt data, inject headers, and more.
|
||||
---
|
||||
|
||||
# IntermediateLayer
|
||||
|
||||
Using the IntermediateLayer is simple as overriding two methods, one for when data is sent and one for when data is received.
|
||||
|
||||
Below is an example included with FishNet which demonstrates using a Caesar cipher to encrypt data.
|
||||
|
||||
You can find this example in the Demos folder, file name **IntermediateLayerCipher.cs**.
|
||||
|
||||
```csharp
|
||||
using FishNet.Managing.Transporting;
|
||||
using System;
|
||||
|
||||
namespace FishNet.Example.IntermediateLayers
|
||||
{
|
||||
/* Below is an example of creating a basic Caesar Cipher.
|
||||
* Bytes are modified by a set value of CIPHER_KEY, and then
|
||||
* the original src ArraySegment is returned.
|
||||
*
|
||||
* It's very important to only iterate the bytes provided
|
||||
* as the segment. For example, if the ArraySegment contains
|
||||
* 1000 bytes but the Offset is 3 and Count is 5 then you should
|
||||
* only iterate bytes on index 3, 4, 5, 6, 7. The code below
|
||||
* shows one way of properly doing so.
|
||||
*
|
||||
* If you are to change the byte array reference, size, or segment
|
||||
* count be sure to return a new ArraySegment with the new values.
|
||||
* For example, if your Offset was 0 and count was 10 but after
|
||||
* encrypting data the Offset was still 0 and count 15 you would
|
||||
* return new ArraySegment<byte>(theArray, 0, 15); */
|
||||
public class IntermediateLayerCipher : IntermediateLayer
|
||||
{
|
||||
private const byte CIPHER_KEY = 5;
|
||||
// Decipher incoming data.
|
||||
public override ArraySegment<byte> HandleIncoming(ArraySegment<byte> src, bool fromServer)
|
||||
{
|
||||
byte[] arr = src.Array;
|
||||
int length = src.Count;
|
||||
int offset = src.Offset;
|
||||
|
||||
for (int i = src.Offset; i < (offset + length); i++)
|
||||
{
|
||||
short next = (short)(arr[i] - CIPHER_KEY);
|
||||
if (next < 0)
|
||||
next += 256;
|
||||
arr[i] = (byte)next;
|
||||
}
|
||||
|
||||
return src;
|
||||
}
|
||||
// Cipher outgoing data.
|
||||
public override ArraySegment<byte> HandleOutgoing(ArraySegment<byte> src, bool toServer)
|
||||
{
|
||||
byte[] arr = src.Array;
|
||||
int length = src.Count;
|
||||
int offset = src.Offset;
|
||||
|
||||
for (int i = offset; i < (offset + length); i++)
|
||||
{
|
||||
short next = (short)(arr[i] + CIPHER_KEY);
|
||||
if (next > byte.MaxValue)
|
||||
next -= 256;
|
||||
arr[i] = (byte)next;
|
||||
}
|
||||
|
||||
return src;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In some cases you may need to inject headers into data sent, such as if you are validating each packet with an authorization key.
|
||||
|
||||
If such is the case it may be wise to reserve a number of bytes needed for your header. You can do this by calling SetMTUReserve() on your TransportManager.\
|
||||
\
|
||||
Here is an example of doing such.
|
||||
|
||||
```csharp
|
||||
public class MyIntermediateLayer : IntermediateLayer
|
||||
{
|
||||
public override void InitializeOnce(TransportManager manager)
|
||||
{
|
||||
base.InitializeOnce(manager);
|
||||
const int bytesForMyHeader = 10;
|
||||
manager.SetMTUReserve(bytesForMyHeader);
|
||||
}
|
||||
// ...rest omitted
|
||||
```
|
||||
Reference in New Issue
Block a user