Skip to main content

Spawner

A class in Root.Township, the global namespace.

Server: spawns count copies of one prefab, or random picks from a distribution, at its spawn points. A component on a networked prefab.

Constructors​

MemberWhat it is
Spawner()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

4 private and internal fields
MemberWhat it is
private int countHow many to spawn (5 by default).
private Distribution distributionDistribution to pick prefabs from when prefab is not set, using the chunk's spawn attributes.
private bool isAllSameWhen true, picks one prefab and spawns it once with a count of count instead of picking each time.
private NetworkPrefab prefabFixed prefab to spawn. Use this or distribution, not both.

Methods​

MemberWhat it is
override void Spawn()Server: spawns the items, unless the entity has no chunk or is being destroyed. With isAllSame it spawns one stack of count.
void SpawnAndReplace()Server: spawns, then replaces this entity with the last thing spawned, keeping the spawned item's position.

Used in​

Members of other types that take, return or hold a Spawner: