ST Object Pool
An ST Object Pool makes a fixed number of copies of one object when the world loads, for things a game shows many
of: projectiles, paint splats, impact effects, shell casings. Add it with Add Component → StageTime → ST Object
Pool and set its template. For copies made only now and then, scripts can also call
Instantiate and Destroy (same template rules); a pool is cheaper for things you
show again and again, because its copies are made once.
| Field | |
|---|---|
template | The object to copy. Keep it inactive, inside your world |
capacity | How many copies to make (1 to 256, default 16) |
autoReturnSeconds | Give each copy back this many seconds after it was spawned. 0 = keep it until you return it |
recycleOldest | When every copy is out, Spawn reuses the oldest one. Off = Spawn returns null instead |
| Member | |
|---|---|
Spawn(position, rotation) | Takes a copy, places it (world space) and activates it, so its particles and sounds with Play On Awake start. Returns the copy, or null |
Return(copy) | Gives a copy back (it is deactivated). Anything else is ignored |
ReturnAll() | Gives every copy back |
activeCount | How many copies are out |
The template can hold renderers, colliders, rigidbodies, particles, trails, lights and audio, but no scripts, StageTime components or Visual Effects (copies would multiply the world's VFX budget; use a Particle System): copies are made after the world is set up, so nothing on them is networked or clickable. The world builder reports a template that breaks these rules.
Copies with colliders are solid for players, and STPhysics queries and
projectiles hit them. An ST Projectile Launcher never hits the copies of its own
projectile pool.
Local, not synced
Each player has their own copies, and nothing about them is synced (unlike VRChat's VRCObjectPool). Spawn from an
event that runs on every device, such as OnProjectileHit or a
network event, with the same position and rotation, and every player sees the same
thing. Work out anything random from the event's details rather than Random, so it matches everywhere:
public override void OnProjectileHit(STProjectileHit hit)
{
// The same roll on every device: derived from where it landed.
float roll = Mathf.Repeat(hit.point.x * 131f + hit.point.y * 71f + hit.point.z * 37f, 360f);
splats.Spawn(hit.point + hit.normal * 0.004f,
Quaternion.LookRotation(-hit.normal) * Quaternion.Euler(0f, 0f, roll));
}
An ST Projectile Launcher draws its projectiles with a pool's copies, and gives them back when they land.