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
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Single player sessions

Netcode for GameObjects provides a [SinglePlayerTransport](xref:Unity.Netcode.Transports.SinglePlayer.SinglePlayerTransport) which derives from [NetworkTransport](xref:Unity.Netcode.NetworkTransport).
Netcode for GameObjects provides a [`SinglePlayerTransport`](xref:Unity.Netcode.Transports.SinglePlayer.SinglePlayerTransport) that derives from [`NetworkTransport`](xref:Unity.Netcode.NetworkTransport).

This provides the ability to run a hosted session using the single player transport without having to modify your primary netcode script.
You can use the `SinglePlayerTransport` to run a single player session without having to modify your primary networking script.

## Adding the single player transport
## Add the single player transport

- Add the `SinglePlayerTransport` to your NetworkManager.
- You can create a custom `MonoBehaviour` component to handle your connection flow or you can derive from `NetworkManager` and add additional methods/logic to handle starting a single player session or multiplayer session.
Expand All @@ -13,6 +13,6 @@ This provides the ability to run a hosted session using the single player transp

## Example script

Below is an example component script that provides a single method to start a single or multi player session:
The following is an example component script that provides a single method to start a single or multiplayer session:

[!code-cs[](../../Tests/Runtime/DocumentationCodeSamples/Configuration/SinglePlayerSessions.cs#SinglePlayerTransportExample)]
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
# Transports

Unity Netcode for GameObjects (Netcode) uses Unity Transport by default and also provides a single player transport.
Use a transport layer to establish communication between your application and different hosts in a network.

## So what is a transport layer?
Netcode for GameObjects uses [Unity Transport](https://docs.unity3d.com/Packages/com.unity.transport@latest) by default and also provides a [single player transport](#single-player-transport).

The transport layer establishes communication between your application and different hosts in a network.
## Introduction to transports

A transport layer can provide:
* *Connection-oriented communication* to ensure a robust connection before exchanging data with a handshake protocol.
* *Maintain order delivery* for your packets to fix any discrepancies from the network layer in case of packet drops or device interruption.
* *Ensure data integrity* by requesting retransmission of missing or corrupted data through using checksums.
* *Control the data flow* in a network connection to avoid buffer overflow or underflow--causing unnecessary network performance issues.
* *Manage network congestion* by mediating flow rates and node overloads.
* *Adjust data streams* to transmit as byte streams or packets.
A transport layer is a software layer that provides communication services between applications on different hosts in a network. It's responsible for establishing, maintaining, and terminating connections, and for delivering data according to the guarantees that the chosen protocol offers.

Transport layers are essential for networked applications. Depending on the protocol and the delivery mode in use, a transport layer can provide the following features:

- *Connection-oriented communication* to ensure a robust connection before exchanging data with a handshake protocol.
- *Maintain order delivery* for your packets to fix any discrepancies from the network layer in case of packet drops or device interruption.
- *Ensure data integrity* by requesting retransmission of missing or corrupted data through using checksums.
- *Control the data flow* in a network connection to avoid buffer overflow or underflow, which can cause unnecessary network performance issues.
- *Manage network congestion* by mediating flow rates and node overloads.
- *Adjust data streams* to transmit as byte streams or packets.

> [!NOTE]
> Not all of these features apply to every message. Netcode for GameObjects supports both reliable and unreliable delivery through the `NetworkDelivery` modes, and messages sent as `Unreliable` or `UnreliableSequenced` can be dropped instead of retransmitted. Refer to [Reliability](./message-system/reliability.md) for more information.

## Unity Transport package

Netcode's default transport Unity Transport is an entire transport layer that you can use to add multiplayer and network features to your project with or without Netcode. Refer to the Transport [documentation](https://docs.unity3d.com/Packages/com.unity.transport@latest) for more information and how to [install](https://docs.unity3d.com/Packages/com.unity.transport@latest?subfolder=/manual/install.html).
Netcode for GameObjects uses the [Unity Transport](https://docs.unity3d.com/Packages/com.unity.transport@latest) package as its default transport layer. Unity Transport is a low-level networking library that provides a high-performance, cross-platform transport layer for multiplayer games and applications. It's designed to be flexible and extensible, allowing developers to implement custom transport protocols if needed.

Netcode provides a [UnityTransport](xref:Unity.Netcode.Transports.UTP.UnityTransport) implementation for easy transport integration with Netcode.
Netcode for GameObjects provides a [`UnityTransport`](xref:Unity.Netcode.Transports.UTP.UnityTransport) class you can use to configure and manage the Unity Transport package. This class provides a simple interface for setting up and managing network connections, as well as sending and receiving data.

## Single player transport

Netcode also provides a [single player transport](./singleplayer.md) that allows for easy switching between multiplayer and single player configurations.
Netcode for GameObjects also provides a [single player transport](./singleplayer.md) that allows for easy switching between multiplayer and single player configurations.

## Community Transports or Writing Your Own
## Custom transports

You can use any of the community contributed custom transport implementations or write your own.
You can use any community-contributed custom transport implementations or write your own.

The community transports are interchangeable transport layers for Netcode and can be installed with the Unity Package Manager. After installation, the transport package will appear in the **Select Transport** dropdown of the NetworkManager. Check out the [Netcode community contributed transports](https://github.com/Unity-Technologies/multiplayer-community-contributions/tree/main/Transports) for more information.
Community transports are interchangeable transport layers for Netcode for GameObjects and can be installed with the Unity Package Manager. After installation, the transport package will appear in the **Select Transport** dropdown of the NetworkManager. Refer to the [Netcode community contributed transports](https://github.com/Unity-Technologies/multiplayer-community-contributions/tree/main/Transports) for more information.

To start writing your own and contributing to the community, check out the [Netcode community contribution repository](https://github.com/Unity-Technologies/multiplayer-community-contributions) for starting points and how to add your content.
To start writing your own transport layer and contributing to the community, refer to the [Netcode community contribution repository](https://github.com/Unity-Technologies/multiplayer-community-contributions) for starting points and how to add your content.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Configure your Netcode for GameObjects project.
| **Topic** | **Description** |
|:--------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------|
| **[Configuring connections](configure-connections.md)** | Configure connections in your project. |
| **[Transports](advanced-topics/transports.md)** | Transport layers establish communication between your application and different hosts in a network. |
| **[Transports](advanced-topics/transports.md)** | Use a transport layer to establish communication between your application and different hosts in a network. |
| **[Unity Relay](relay/relay.md)** | Use Unity Relay with Netcode for GameObjects to connect clients and hosts over the internet using a relay server. |
| **[Command-line arguments](command-line-arguments.md)** | Use command-line arguments to configure certain aspects of your game at launch. |