Class NetworkSpawnManager
Class that handles object spawning
Namespace: Unity.Netcode
Syntax
public class NetworkSpawnManager
Fields
OwnershipToObjectsTable
Use to get all NetworkObjects owned by a client Ownership to Objects Table Format: [ClientId][NetworkObjectId][NetworkObject] Server: Keeps track of all clients' ownership Client: Keeps track of only its ownership
Declaration
public readonly Dictionary<ulong, Dictionary<ulong, NetworkObject>> OwnershipToObjectsTable
Field Value
Type | Description |
---|---|
Dictionary<UInt64, Dictionary<UInt64, NetworkObject>> |
SpawnedObjects
The currently spawned objects
Declaration
public readonly Dictionary<ulong, NetworkObject> SpawnedObjects
Field Value
Type | Description |
---|---|
Dictionary<UInt64, NetworkObject> |
SpawnedObjectsList
A list of the spawned objects
Declaration
public readonly HashSet<NetworkObject> SpawnedObjectsList
Field Value
Type | Description |
---|---|
HashSet<NetworkObject> |
Properties
NetworkManager
Gets the NetworkManager associated with this SpawnManager.
Declaration
public NetworkManager NetworkManager { get; }
Property Value
Type | Description |
---|---|
NetworkManager |
Methods
GetClientOwnedObjects(UInt64)
Returns a list of all NetworkObjects that belong to a client.
Declaration
public List<NetworkObject> GetClientOwnedObjects(ulong clientId)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | clientId | the client's id LocalClientId |
Returns
Type | Description |
---|---|
List<NetworkObject> | returns the list of NetworkObjects owned by the client |
GetLocalPlayerObject()
Returns the local player object or null if one does not exist
Declaration
public NetworkObject GetLocalPlayerObject()
Returns
Type | Description |
---|---|
NetworkObject | The local player object or null if one does not exist |
GetPlayerNetworkObject(UInt64)
Returns the player object with a given clientId or null if one does not exist. This is only valid server side.
Declaration
public NetworkObject GetPlayerNetworkObject(ulong clientId)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | clientId | the client identifier of the player |
Returns
Type | Description |
---|---|
NetworkObject | The player object with a given clientId or null if one does not exist |