diff --git a/Assets/Scripts/Game/Shark.cs b/Assets/Scripts/Game/Shark.cs index 03caa21..c577f2e 100644 --- a/Assets/Scripts/Game/Shark.cs +++ b/Assets/Scripts/Game/Shark.cs @@ -15,7 +15,7 @@ public class Shark : MonoBehaviour public SpriteRenderer gameBoardSpriteRenderer; - private Bounds gameBoardBounds; + private Bounds? gameBoardBounds = null; private AudioSource audioSource; @@ -44,7 +44,6 @@ public class Shark : MonoBehaviour { audioSource = GetComponent(); animator = GetComponent(); - gameBoardBounds = gameBoardSpriteRenderer.bounds; bool spawnLeft = Random.Range(0, 2) == 0; angle = spawnLeft ? 90 : 270; @@ -55,6 +54,11 @@ public class Shark : MonoBehaviour // Update is called once per frame void FixedUpdate() { + if (gameBoardSpriteRenderer != null && gameBoardBounds == null) + { + gameBoardBounds = gameBoardSpriteRenderer.bounds; + } + // Check if the spawn animation has finished. if ( (animator.GetCurrentAnimatorStateInfo(0).IsName("SharkSpawnRight") || diff --git a/Assets/Scripts/Game/Spawners/SharkSpawner.cs b/Assets/Scripts/Game/Spawners/SharkSpawner.cs index 98f707b..3ad7709 100644 --- a/Assets/Scripts/Game/Spawners/SharkSpawner.cs +++ b/Assets/Scripts/Game/Spawners/SharkSpawner.cs @@ -14,7 +14,7 @@ public class SharkSpawner : MonoBehaviour private bool isActive = true; - private static float spawnProbability = 0.1f; + private static float spawnProbability = 0.9f; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start()