reckfellENGINE

MultiplayerSpawner

Automatically replicates spawnable nodes from the authority to other multiplayer peers.

On this page
class MultiplayerSpawnerReckfellSharpInherits Entity

Automatically replicates spawnable nodes from the authority to other multiplayer peers.

Spawnable scenes can be configured in the editor or through code (see MultiplayerSpawner.AddSpawnableScene). Also supports custom node spawns through MultiplayerSpawner.Spawn, calling MultiplayerSpawner.SpawnFunction on all peers. Internally, MultiplayerSpawner uses MultiplayerApi.ObjectConfigurationAdd to notify spawns passing the spawned node as the object and itself as the configuration, and MultiplayerApi.ObjectConfigurationRemove to notify despawns in a similar way.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

MultiplayerSpawnerConstructor
# MultiplayerSpawner
C#
public MultiplayerSpawner();

Properties4

SpawnFunctionProperty
# SpawnFunction
C#
public Callable SpawnFunction { get; set; }

Method called on all peers when a custom MultiplayerSpawner.Spawn is requested by the authority. Will receive the data parameter, and should return a Entity that is not in the scene tree. Note: The returned node should not be added to the scene with Entity.AddChild. This is done automatically.

SpawnLimitProperty
# SpawnLimit
C#
public uint SpawnLimit { get; set; }

Maximum number of nodes allowed to be spawned by this spawner. Includes both spawnable scenes and custom spawns. When set to 0 (the default), there is no limit.

SpawnPathProperty
# SpawnPath
C#
public EntityPath SpawnPath { get; set; }

Path to the spawn root. Spawnable scenes that are added as direct children are replicated to other peers.

_SpawnableScenesProperty
# _SpawnableScenes
C#
public string[] _SpawnableScenes { get; set; }

Methods11

AddSpawnableScenevoid
# AddSpawnableScene
C#
public void AddSpawnableScene(string path);

Adds a scene path to spawnable scenes, making it automatically replicated from the multiplayer authority to other peers when added as children of the node pointed by MultiplayerSpawner.SpawnPath.

Parameters
NameTypeDefault
pathstring—
ClearSpawnableScenesvoid
# ClearSpawnableScenes
C#
public void ClearSpawnableScenes();

Clears all spawnable scenes. Does not despawn existing instances on remote peers.

GetSpawnFunctionCallable
# GetSpawnFunction
C#
public Callable GetSpawnFunction();
Returns Callable
GetSpawnLimituint
# GetSpawnLimit
C#
public uint GetSpawnLimit();
Returns uint
GetSpawnPathEntityPath
# GetSpawnPath
C#
public EntityPath GetSpawnPath();
Returns EntityPath
GetSpawnableScenestring
# GetSpawnableScene
C#
public string GetSpawnableScene(int index);

Returns the spawnable scene path by index.

Parameters
NameTypeDefault
indexint—
Returns string
GetSpawnableSceneCountint
# GetSpawnableSceneCount
C#
public int GetSpawnableSceneCount();

Returns the count of spawnable scene paths.

Returns int
SetSpawnFunctionvoid
# SetSpawnFunction
C#
public void SetSpawnFunction(Callable spawnFunction);
Parameters
NameTypeDefault
spawnFunctionCallable—
SetSpawnLimitvoid
# SetSpawnLimit
C#
public void SetSpawnLimit(uint limit);
Parameters
NameTypeDefault
limituint—
SetSpawnPathvoid
# SetSpawnPath
C#
public void SetSpawnPath(EntityPath path);
Parameters
NameTypeDefault
pathEntityPath—
SpawnEntity
# Spawn
C#
public Entity Spawn(Variant data = default);

Requests a custom spawn, with data passed to MultiplayerSpawner.SpawnFunction on all peers. Returns the locally spawned node instance already inside the scene tree, and added as a child of the node pointed by MultiplayerSpawner.SpawnPath. Note: Spawnable scenes are spawned automatically. MultiplayerSpawner.Spawn is only needed for custom spawns.

Parameters
NameTypeDefault
dataVariantdefault
Returns Entity

Signals and events2

DespawnedEvent
# Despawned
C#
public event MultiplayerSpawner.DespawnedEventHandler Despawned;

Emitted when a spawnable scene or custom spawn was despawned by the multiplayer authority. Only called on remote peers.

Handler parameters
NameTypeDefault
nodeEntity—
SpawnedEvent
# Spawned
C#
public event MultiplayerSpawner.SpawnedEventHandler Spawned;

Emitted when a spawnable scene or custom spawn was spawned by the multiplayer authority. Only called on remote peers.

Handler parameters
NameTypeDefault
nodeEntity—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.