Default spawn locator that performs physics raycasts and NavMesh sampling to produce valid placement positions for spawned objects.
More...
|
void | Configure (LayerMask mask, float minSpawnRange, float cullDistance, string[] navmeshAreas) |
| Configures sampling parameters and NavMesh area mask.- Parameters
-
mask | Physics layers considered as ground when raycasting down. |
minSpawnRange | Minimum allowed distance from the player. |
cullDistance | Max search radius around the player for global placement. |
navmeshAreas | Optional NavMesh area names to restrict placement. |
|
|
void | ConfigureHints (bool enabled, SpawnHintSettings settings) |
| Enables/disables the hint system and supplies settings.- Parameters
-
enabled | Whether hint lookups should be attempted. |
settings | Hint parameters asset (cell size, LOS mask, etc.). |
|
|
Vector3 | FindForGlobal (Vector3 playerPos) |
| Finds a NavMesh-valid position for global spawning around the player.- Parameters
-
playerPos | World position of the player. |
|
|
Vector3 | FindNearParent (Vector3 parentPos, Vector3 playerPos) |
| Finds a NavMesh-valid position near a group parent (for clustered spawns).- Parameters
-
parentPos | World position of the group parent. |
playerPos | World position of the player. |
|
|
Vector3 | FindForRegion (Bounds bounds, float regionHeight, Vector3 playerPos) |
| Finds a NavMesh-valid position inside a region’s bounds.- Parameters
-
regionBounds | Region world-space AABB. |
regionHeight | Y height to apply after placement (for visual consistency). |
playerPos | World position of the player. |
|
|
Vector3 | FindForWave (Transform point, float range, Vector3 playerPos, string[] hintTags=null) |
| Finds a NavMesh-valid position near a specific wave/special anchor point.- Parameters
-
spawnPoint | Anchor transform. |
spawnRange | Radius to sample around the anchor. |
playerPos | World position of the player. |
hintTags | Optional tag filter coming from WaveSpawnPoint.AnchorTags. |
|
|
|
static bool | IsInvalid (Vector3 v) |
| Checks whether a vector is the sentinel invalid position.
|
|
|
bool | TryFromHints (Vector3 center, float searchRadius, Vector3 playerPos, out Vector3 posOut, string[] requestTags=null) |
| Tries to choose a position from EnemySpawnHintPoint around center . If requestTags is provided, the first pass prefers hints that match at least one tag. If none qualify, a second pass accepts any eligible hint. Returns false if no hint passes checks.
|
|
bool | HasPlayerLOS (Vector3 playerPos, Vector3 candidate) |
| Returns true if there is no blocking collider between player and candidate (i.e., player can see it).
|
|
Vector3 | RaycastDown (Vector3 pos) |
| Raycasts downward to find ground on the configured physics layers. Returns the hit point if found, otherwise the input position.
|
|
bool | ValidVsPlayer (Vector3 pos, Vector3 playerPos) |
| Ensures pos is at least _minRange away from the player.
|
|
bool | NavSample (ref Vector3 pos, float maxDist) |
| Samples the NavMesh near pos restricted to _areaMask. On success, updates pos to the sampled position.
|
|
Vector3 | Fallback (Vector3 around) |
| Best-effort fallback using NavMesh.FindClosestEdge; returns the input position if none found.
|
|
|
static bool | TagsMatch (string[] requested, string[] candidate) |
| Returns true if any non-empty requested tag appears in candidate .
|
|
static int | BuildAreaMask (string[] names) |
| Builds a NavMesh area bitmask from area names; returns NavMesh.AllAreas if none or not found.
|
|
Default spawn locator that performs physics raycasts and NavMesh sampling to produce valid placement positions for spawned objects.
◆ BuildAreaMask()
static int MegaCrush.Spawner.SpawnLocator.BuildAreaMask |
( |
string[] | names | ) |
|
|
staticprivate |
Builds a NavMesh area bitmask from area names; returns NavMesh.AllAreas if none or not found.
◆ Configure()
void MegaCrush.Spawner.SpawnLocator.Configure |
( |
LayerMask | mask, |
|
|
float | minSpawnRange, |
|
|
float | cullDistance, |
|
|
string[] | navmeshAreas ) |
Configures sampling parameters and NavMesh area mask.
- Parameters
-
mask | Physics layers considered as ground when raycasting down. |
minSpawnRange | Minimum allowed distance from the player. |
cullDistance | Max search radius around the player for global placement. |
navmeshAreas | Optional NavMesh area names to restrict placement. |
Implements MegaCrush.Spawner.ISpawnLocator.
◆ ConfigureHints()
void MegaCrush.Spawner.SpawnLocator.ConfigureHints |
( |
bool | enabled, |
|
|
SpawnHintSettings | settings ) |
Enables/disables the hint system and supplies settings.
- Parameters
-
enabled | Whether hint lookups should be attempted. |
settings | Hint parameters asset (cell size, LOS mask, etc.). |
Implements MegaCrush.Spawner.ISpawnLocator.
◆ Fallback()
Vector3 MegaCrush.Spawner.SpawnLocator.Fallback |
( |
Vector3 | around | ) |
|
|
private |
Best-effort fallback using NavMesh.FindClosestEdge; returns the input position if none found.
◆ FindForGlobal()
Vector3 MegaCrush.Spawner.SpawnLocator.FindForGlobal |
( |
Vector3 | playerPos | ) |
|
Finds a NavMesh-valid position for global spawning around the player.
- Parameters
-
playerPos | World position of the player. |
Implements MegaCrush.Spawner.ISpawnLocator.
◆ FindForRegion()
Vector3 MegaCrush.Spawner.SpawnLocator.FindForRegion |
( |
Bounds | bounds, |
|
|
float | regionHeight, |
|
|
Vector3 | playerPos ) |
Finds a NavMesh-valid position inside a region’s bounds.
- Parameters
-
regionBounds | Region world-space AABB. |
regionHeight | Y height to apply after placement (for visual consistency). |
playerPos | World position of the player. |
Implements MegaCrush.Spawner.ISpawnLocator.
◆ FindForWave()
Vector3 MegaCrush.Spawner.SpawnLocator.FindForWave |
( |
Transform | point, |
|
|
float | range, |
|
|
Vector3 | playerPos, |
|
|
string[] | hintTags = null ) |
Finds a NavMesh-valid position near a specific wave/special anchor point.
- Parameters
-
spawnPoint | Anchor transform. |
spawnRange | Radius to sample around the anchor. |
playerPos | World position of the player. |
hintTags | Optional tag filter coming from WaveSpawnPoint.AnchorTags. |
Implements MegaCrush.Spawner.ISpawnLocator.
◆ FindNearParent()
Vector3 MegaCrush.Spawner.SpawnLocator.FindNearParent |
( |
Vector3 | parentPos, |
|
|
Vector3 | playerPos ) |
Finds a NavMesh-valid position near a group parent (for clustered spawns).
- Parameters
-
parentPos | World position of the group parent. |
playerPos | World position of the player. |
Implements MegaCrush.Spawner.ISpawnLocator.
◆ HasPlayerLOS()
bool MegaCrush.Spawner.SpawnLocator.HasPlayerLOS |
( |
Vector3 | playerPos, |
|
|
Vector3 | candidate ) |
|
private |
Returns true if there is no blocking collider between player and candidate (i.e., player can see it).
◆ IsInvalid()
static bool MegaCrush.Spawner.SpawnLocator.IsInvalid |
( |
Vector3 | v | ) |
|
|
static |
Checks whether a vector is the sentinel invalid position.
◆ NavSample()
bool MegaCrush.Spawner.SpawnLocator.NavSample |
( |
ref Vector3 | pos, |
|
|
float | maxDist ) |
|
private |
Samples the NavMesh near pos restricted to _areaMask. On success, updates pos to the sampled position.
◆ RaycastDown()
Vector3 MegaCrush.Spawner.SpawnLocator.RaycastDown |
( |
Vector3 | pos | ) |
|
|
private |
Raycasts downward to find ground on the configured physics layers. Returns the hit point if found, otherwise the input position.
◆ TagsMatch()
static bool MegaCrush.Spawner.SpawnLocator.TagsMatch |
( |
string[] | requested, |
|
|
string[] | candidate ) |
|
staticprivate |
Returns true if any non-empty requested tag appears in candidate .
◆ TryFromHints()
bool MegaCrush.Spawner.SpawnLocator.TryFromHints |
( |
Vector3 | center, |
|
|
float | searchRadius, |
|
|
Vector3 | playerPos, |
|
|
out Vector3 | posOut, |
|
|
string[] | requestTags = null ) |
|
private |
Tries to choose a position from EnemySpawnHintPoint around center . If requestTags is provided, the first pass prefers hints that match at least one tag. If none qualify, a second pass accepts any eligible hint. Returns false
if no hint passes checks.
◆ ValidVsPlayer()
bool MegaCrush.Spawner.SpawnLocator.ValidVsPlayer |
( |
Vector3 | pos, |
|
|
Vector3 | playerPos ) |
|
private |
Ensures pos is at least _minRange away from the player.
◆ _areaMask
int MegaCrush.Spawner.SpawnLocator._areaMask |
|
private |
◆ _cullDistance
float MegaCrush.Spawner.SpawnLocator._cullDistance |
|
private |
◆ _hints
◆ _mask
LayerMask MegaCrush.Spawner.SpawnLocator._mask |
|
private |
◆ _minRange
float MegaCrush.Spawner.SpawnLocator._minRange |
|
private |
◆ _useHints
bool MegaCrush.Spawner.SpawnLocator._useHints |
|
private |
◆ InvalidPos
readonly Vector3 MegaCrush.Spawner.SpawnLocator.InvalidPos = new Vector3(float.NaN, float.NaN, float.NaN) |
|
staticprivate |
Sentinel returned when Hint-Only is on and no hint qualifies.
◆ s_WarnedInvalidWindow
readonly HashSet<EnemySpawnHintPoint> MegaCrush.Spawner.SpawnLocator.s_WarnedInvalidWindow = new() |
|
staticprivate |
◆ s_WarnedRangeClash
readonly HashSet<EnemySpawnHintPoint> MegaCrush.Spawner.SpawnLocator.s_WarnedRangeClash = new() |
|
staticprivate |
The documentation for this class was generated from the following file:
- D:/projects/Asset Store Packages/com.pixelwizards.runtimespawner/Code/Runtime/Internals/SpawnLocator.cs