Skip to content

Commit 4ae51fa

Browse files
committed
Update safety in spawn position
1 parent 042a365 commit 4ae51fa

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Assets/_Project/Scripts/Players/PlayerManager.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ public void PlayEvent (FeedData feed)
240240
*/
241241
Vector3 GetClearSpawnPosition ()
242242
{
243-
Vector3 spawnPosition = new Vector3 ();
244-
float startTime = Time.realtimeSinceStartup;
243+
Vector3 spawnPosition = Vector3.zero;
244+
int safety = 0;
245245
bool positionClear = false;
246246
int layerMask = (1 << 8); // only Layer 8 "Players"
247247
//Debug.Log ("PlayerManager.GetClearSpawnPosition() bounds = " + worldContainerCollider.bounds.ToString ());
@@ -254,12 +254,13 @@ Vector3 GetClearSpawnPosition ()
254254
Collider [] hitColliders = Physics.OverlapSphere (spawnPosition, 0.75f, layerMask);
255255
// if collider isn't touching another player collider then set true to stop loop
256256
if (hitColliders.Length <= 0) positionClear = true;
257-
// else continue until time has run out
258-
if (Time.realtimeSinceStartup - startTime > 0.5f) {
259-
Debug.Log ("Time out placing GameObject!");
260-
return Vector3.zero;
257+
// safety
258+
if (++safety > 10) {
259+
Debug.Log ("PlayerManager.GetClearSpawnPosition() - Safety first!");
260+
return spawnPosition;
261261
}
262262
}
263+
//Debug.Log ("PlayerManager.GetClearSpawnPosition() spawnPosition = " + spawnPosition.ToString ());
263264
return spawnPosition;
264265
}
265266

@@ -286,7 +287,7 @@ public static Vector3 RandomPointInBounds (Bounds bounds)
286287
/// <param name="destroyDelay">Destroy delay</param>
287288
void AttachDetachAnimation (GameObject prefab, bool randomPosition, float scaleMultiplier, float destroyDelay = -1f)
288289
{
289-
Debug.Log ("AttachDetachAnimation() prefab.name = " + prefab.name);
290+
//Debug.Log ("AttachDetachAnimation() prefab.name = " + prefab.name);
290291

291292

292293
// ATTACH THE GAME OBJECT WITH ANIMATION
@@ -337,7 +338,7 @@ IEnumerator ResetEffectPlayingState (float wait)
337338

338339
IEnumerator PlayBattleEffects (FeedData feed)
339340
{
340-
Debug.Log ("PlayBattle() feed = " + feed.ToString ());
341+
//Debug.Log ("PlayBattle() feed = " + feed.ToString ());
341342

342343

343344
// start battle

0 commit comments

Comments
 (0)