Class NetConfig

Namespace
Unity.Multiplayer.Core

Everything a session needs to start: topology, endpoint, transport, tick rate, capacity and the game version clients must match. The topology is configuration, not code (BIBLE UM-§2): the same game runs as host, dedicated server or client by changing this object.

public sealed class NetConfig
Inheritance
NetConfig
Inherited Members

Remarks

A plain mutable settings object so a bootstrap, a command line or a server.json can fill it field by field. Call Validate() (or EnsureValid()) before starting.

Fields

AnyAddress

Address a Host or Server binds when Address is empty: every interface.

public const string AnyAddress = "0.0.0.0"

Field Value

string

DefaultMaxPlayers

Default maximum number of players, the host's own player included.

public const int DefaultMaxPlayers = 8

Field Value

int

DefaultPort

Default port (Unity Transport's conventional 7777).

public const ushort DefaultPort = 7777

Field Value

ushort

DefaultReconnectGraceSeconds

Default seconds a dropped player's seat is held for them to reconnect.

public const double DefaultReconnectGraceSeconds = 60

Field Value

double

DefaultTickRate

Default simulation and network tick rate, in ticks per second.

public const int DefaultTickRate = 30

Field Value

int

LoopbackAddress

Address a Client connects to when Address is empty: this machine.

public const string LoopbackAddress = "127.0.0.1"

Field Value

string

MaxMaxPlayers

Highest player count accepted by Validate().

public const int MaxMaxPlayers = 1024

Field Value

int

MaxReconnectGraceSeconds

Longest accepted ReconnectGraceSeconds (one day).

public const double MaxReconnectGraceSeconds = 86400

Field Value

double

MaxServerNameLength

Longest accepted ServerName, in characters.

public const int MaxServerNameLength = 64

Field Value

int

MaxTickRate

Highest tick rate accepted by Validate().

public const int MaxTickRate = 128

Field Value

int

Properties

Address

For a Client, the server address to connect to; for a Host or Server, the local address to bind. Empty or null means the default for the topology (see EffectiveAddress).

public string Address { get; set; }

Property Value

string

Conditions

Simulated network conditions (latency, jitter, packet loss) for this peer's link, for testing how the game plays on a bad connection. None (the default) simulates nothing; Custom uses SimulatedLatencyMs, SimulatedJitterMs and SimulatedPacketLossPercent. Editor and development builds only (see NetConditions).

public NetConditionsProfile Conditions { get; set; }

Property Value

NetConditionsProfile

EffectiveAddress

The address actually used: Address, or the topology's default when it is empty.

public string EffectiveAddress { get; }

Property Value

string

EffectiveConditions

The conditions Conditions stands for: a named profile's numbers, or the custom ones.

public NetConditions EffectiveConditions { get; }

Property Value

NetConditions

GameVersion

The game's version string. Connection approval rejects a client whose version differs.

public string GameVersion { get; set; }

Property Value

string

IsValid

True when Validate() finds no problems.

public bool IsValid { get; }

Property Value

bool

JoinCodes

Which service publishes and resolves join codes. Auto (the default) means Relay for a listen server and the rendezvous service for a dedicated server (JoinCodeDefaults).

public JoinCodeProvider JoinCodes { get; set; }

Property Value

JoinCodeProvider

MaxPlayers

Maximum connected players, the host's own player included.

public int MaxPlayers { get; set; }

Property Value

int

Password

Server: the password every client must send to be let in (empty lets anyone in). Client: the password it sends. Set by server.json "password", -password or MINDATTIC_SERVER_PASSWORD. Never included in ToString().

public string Password { get; set; }

Property Value

string

Port

For a Client, the server's port; for a Host or Server, the port to listen on.

public ushort Port { get; set; }

Property Value

ushort

PublicAddress

The address players reach this server at, when it differs from what it binds (behind NAT or a proxy). Empty lets the rendezvous service use the address the registration came from (ServerAdvertisement).

public string PublicAddress { get; set; }

Property Value

string

PublicPort

The port players reach this server at, when a host maps it (0, the default, means Port, or the RUNPOD_TCP_PORT_* mapping on RunPod; see ServerAdvertisement).

public ushort PublicPort { get; set; }

Property Value

ushort

ReconnectGraceSeconds

Server side: how long a dropped player's seat (and player object) waits for the same player token to reconnect before it is freed. Zero frees it at once.

public double ReconnectGraceSeconds { get; set; }

Property Value

double

RendezvousSecret

The rendezvous service's registration secret, which a dedicated server needs to register. Prefer the MINDATTIC_RENDEZVOUS_SECRET environment variable (NetEnvironment) to keeping it in a scene. Never included in ToString().

public string RendezvousSecret { get; set; }

Property Value

string

RendezvousUrl

Base URL of the self-hosted rendezvous service (for example https://rendezvous.example.com). A dedicated server with one registers itself as soon as it is running; a client resolves codes with it. Empty for none.

public string RendezvousUrl { get; set; }

Property Value

string

ServerName

The name a server shows players (its health endpoint and server list). Empty for none. Set by server.json "name" or -name.

public string ServerName { get; set; }

Property Value

string

SimulatedJitterMs

With Custom: random variation of that delay, in milliseconds (JitterMs).

public int SimulatedJitterMs { get; set; }

Property Value

int

SimulatedLatencyMs

With Custom: milliseconds added to each packet sent and received (LatencyMs).

public int SimulatedLatencyMs { get; set; }

Property Value

int

SimulatedPacketLossPercent

With Custom: percentage of packets dropped each way (PacketLossPercent).

public int SimulatedPacketLossPercent { get; set; }

Property Value

int

TickInterval

Seconds per tick (1 / TickRate). Only meaningful once the config is valid.

public double TickInterval { get; }

Property Value

double

TickRate

Ticks per second for the network tick and the server simulation. Default 30.

public int TickRate { get; set; }

Property Value

int

Topology

Whether this process hosts, serves or joins.

public Topology Topology { get; set; }

Property Value

Topology

Transport

The transport to run over.

public TransportKind Transport { get; set; }

Property Value

TransportKind

Methods

Clone()

Returns a field-by-field copy.

public NetConfig Clone()

Returns

NetConfig

EnsureValid()

Throws ArgumentException listing every problem if the config is invalid.

public void EnsureValid()

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

UseCustomConditions()

Switches Conditions to Custom, starting the custom numbers from the profile chosen so far, so one of them can be changed and the rest kept (-netsim mobile4g -loss 10). Does nothing when the profile is already Custom.

public void UseCustomConditions()

Validate()

Lists every problem with this config; an empty list means it is valid.

public IReadOnlyList<string> Validate()

Returns

IReadOnlyList<string>