SpawnArea
A class in Root.Township, the global namespace.
A circle on the ground where things (or players) spawn. Gives repeatable positions by index, raycast onto valid ground away from blocking layers. Named areas are listed in InstanceMap.
- Listed in Global namespace: S
- Inherits or implements
MonoBehaviour,ISavable<SpawnAreaSaveData>,ISavableSave<SpawnAreaSaveData>,ISavableSaveBase,ISpawnPositions - Derived types
SpawnAreaSaveData
Constructors
| Member | What it is |
|---|---|
SpawnArea() | Creates a SpawnArea with default values. |
Fields
| Member | What it is |
|---|---|
static Dictionary<SpawnAreaIdentifier, SpawnArea> InstanceMap | Every spawn area with a non-default identifier, by identifier. |
9 private and internal fields
| Member | What it is |
|---|---|
private float avoidCastRadius | Radius checked around a spot for avoid-layer objects. Below 0 skips the check. |
private LayerMask avoidLayers | Layers that block a spawn spot, both when hit by the ground ray and nearby. |
private LayerMask groundLayers | Layers counted as ground for the downward raycast. |
private SpawnAreaIdentifier identifier | Backing field for Identifier. Non-default areas register in InstanceMap, for example the respawn point. |
private bool isAligningNormal | Whether spawn rotation tilts to match the ground normal. |
private float maxAcceptableAngleDot | Lowest ground normal y (set from an angle) a spot can have. -1 allows any slope. |
private int maxIterations | Random tries before falling back to the area's centre (100 by default). |
private int seed | Random seed picked in Awake, so the same index gives the same spot during a session. |
private float size | Radius of the circle spawn spots are picked in. |
Properties
| Member | What it is |
|---|---|
SpawnAreaIdentifier Identifier { get; } | Which named spawn area this is. |
Methods
| Member | What it is |
|---|---|
void Awake() | Picks a random seed and adds the area to InstanceMap if it's named. |
Vector3 GetRandomSpawnPosition() | A valid position from a random index. |
SpawnPoint GetSpawnPosition(int index) | The spawn point for an index. The same index gives the same point while the seed lasts. Falls back to the centre. |
3 private and internal methods
Used in
Members of other types that take, return or hold a SpawnArea:
INetworkScene.RespawnPoint, NetworkScene.Alta.Networking.INetworkScene.RespawnPoint, NetworkScene.respawnPoint, GymnasiumOnDemandPrefabSpawner.spawnArea, GymnasiumTeleportPointPage.SetupElement, GymnasiumTeleportPointPage.teleportPoints, InGameInspector.SpawnPointTeleporter.availablePoints, LocalNetworkScene.RespawnPoint, LocalNetworkScene.spawnArea, TeleportPointElement.Setup, TeleportPointElement.spawnPoint, TeleportPointElement.SpawnPoint.