ST Networked Pool
An ST Networked Pool is a fixed set of copies of one object that every player sees the same way, like VRChat's
VRCObjectPool. Use it for game pieces, tokens, balls, enemies or props that appear and disappear during a game.
Scripts cannot create objects, so StageTime makes the copies when the world loads, and the pool's owner takes them
out and puts them back. Add it with Add Component → StageTime → ST Networked Pool and set its template.
| Field | |
|---|---|
template | The object to copy. It becomes copy 0. Keep it inactive, where the copies should appear: the copies are made next to it, as its siblings |
capacity | How many copies there are, the template included (1 to 64, default 8) |
| Member | |
|---|---|
TryToSpawn() | Owner only. Activates a free copy for everyone and returns it. Returns null for other players, when every copy is out, or when the pool spawns too fast |
Return(copy) | Owner only. Deactivates a copy for everyone. Anything that is not one of this pool's spawned copies is ignored |
GetCopy(index) | The copy at index (0 to capacity - 1; copy 0 is the template), or null |
activeCount | How many copies are out, the same for everyone |
IsSpawned(copy) | True if it is one of this pool's copies and is out |
Copies get OnEnable when they are spawned and OnDisable when they are returned, on every device.
What a copy can hold
Copies are part of your world, so unlike ST Object Pool copies they can hold:
- scripts, with their own
[Synced]values and owner per copy; - ST Pickup and ST Object Sync, so copies can be grabbed, thrown and moved for everyone;
- ST Hitbox and ST Spatial Audio Source;
- colliders and plain Unity components: renderers, particles, lights, audio, UI.
Other StageTime components (seats, video players, queues, drawing surfaces, mirrors, launchers and other pools) and Visual Effects are not allowed in a template. The world builder reports a template that breaks these rules.
Ownership
Only the pool's owner can spawn and return copies; everyone else sees the result. Put your script on the pool's GameObject, take ownership, and spawn once ownership has arrived:
public STNetworkedPool pool;
private bool wantSpawn;
public override void Interact()
{
if (Networking.IsOwner(gameObject) && pool.TryToSpawn() != null) return;
wantSpawn = true; // spawn when ownership arrives
Networking.SetOwner(Networking.LocalPlayer, gameObject);
}
public override void OnOwnershipTransferred(StageTimePlayer player)
{
if (player.isLocal && wantSpawn) pool.TryToSpawn();
wantSpawn = false;
}
Right after SetOwner, Networking.IsOwner is already true (so your [Synced] writes work at once), but the pool
only accepts TryToSpawn and Return once ownership has arrived. Until then they return null or do nothing. When the
owner leaves, the room's master becomes the pool's owner. Each copy has its own owner, like any object.
Good to know
- Players who join later see the copies that are out.
- Synced values are kept when a copy is returned, as in VRChat. Reset them yourself when you spawn the copy again.
- Don't call
SetActiveon a copy yourself. The pool would show it differently on other devices until that copy is spawned or returned again. UseTryToSpawnandReturn. - Positions are not part of the pool. A spawned copy appears where it was last left on each device. Give copies an ST Object Sync (or an ST Pickup) when they move, and move them as their owner.
- Scripts on a copy load when it is first spawned, so a big pool costs little until its copies are used. Before that, calling another script's members on the copy does nothing (with one warning).
TryToSpawntakes the free copy with the lowest number. VRChat'sShuffleis not available.
Limits
| Limit | |
|---|---|
| Copies per pool | 64 |
| Networked pools per world | 16 |
| Networked objects in all copies together (a copy's GameObject with scripts, a pickup or an Object Sync counts as one) | 128 |
| Script instances in all copies together | 128 |
| Spawns | 20 a second per pool, after a burst of 64; TryToSpawn returns null over it |
Every world runs on Quest and phones, so these are the limits for every world. Spawning and returning send almost nothing: the pool syncs one bit per copy.
In local preview the pool makes plain local copies, so your scripts can spawn and return them as the only player.
See the Pool deck example.