void Update() { float waterHeight = water.position.y; float cameraHeight = camera.position.y - waterHeight; // aboveWater int cloudDensity = (int)Mathf.Lerp(minCloudDensity, maxCloudDensity, map(cameraHeight, cloudHeightMinDensity, cloudHeightMaxDensity, 0, 1)); clouds.maxParticles = cloudDensity; if (cameraHeight < cloudHeightMinDensity && !clouds.isStopped) { clouds.Stop(); } else if (cameraHeight > cloudHeightMinDensity && clouds.isStopped) { clouds.Play(); } if (cameraHeight < 0 && !snow.isStopped) { snow.Stop(); } else if (cameraHeight > 0 && snow.isStopped) { snow.Play(); } if (cameraHeight < 0 && !underwater) { underwater = true; ppManager.OnEnteringWater(); //RenderSettings.fogColor = waterFogColor; audioRegular.SetAudioMixerGroup(audioUnderwater); audioAlternate.SetAudioMixerGroup(audioUnderwater); } else if (cameraHeight > 0 && underwater) { underwater = false; ppManager.OnExitingWater(); //RenderSettings.fogColor = WorldGenerator.Instance.currentFogColor; audioRegular.SetAudioMixerGroup(audioMaster); audioAlternate.SetAudioMixerGroup(audioMaster); } //debug : if (Input.GetKeyDown(KeyCode.U)) { transform.position += Vector3.up * 100; } }