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. |
|
|
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) |
| 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. |
|
|
|
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 the position 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 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.
◆ 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 ) |
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. |
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.
◆ 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.
◆ ValidVsPlayer()
bool MegaCrush.Spawner.SpawnLocator.ValidVsPlayer |
( |
Vector3 | pos, |
|
|
Vector3 | playerPos ) |
|
private |
Ensures the position is at least _minRange away from the player.
◆ _areaMask
int MegaCrush.Spawner.SpawnLocator._areaMask |
|
private |
◆ _cullDistance
float MegaCrush.Spawner.SpawnLocator._cullDistance |
|
private |
◆ _mask
LayerMask MegaCrush.Spawner.SpawnLocator._mask |
|
private |
◆ _minRange
float MegaCrush.Spawner.SpawnLocator._minRange |
|
private |
The documentation for this class was generated from the following file:
- D:/projects/Asset Store Packages/com.pixelwizards.runtimespawner/Code/Runtime/Internals/SpawnLocator.cs