void FixedUpdate() { acc = GetInput(); acc += offset; // If the level is not in fading and readyToMove then move the player if (!fc.inFade && readyToMove) { // Move the player rb.AddForce(new Vector3(acc.x * moveModifier, 0, acc.y * moveModifier) * speed); } // If the player fell down into nothingness then fade to black if (transform.position.y <= -5 && !death) { if (!DeathAudio) { PlayAudio(DeathAudioClip); DeathAudio = true; } // Fade out the level fc.BeginFade(1, true); death = true; } // When the screen is black reload the level if (fc.alpha >= deathAlpha && !win) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } else if (fc.alpha >= 1 && win) { if (SceneManager.sceneCountInBuildSettings == SceneManager.GetActiveScene().buildIndex + 1) { SceneManager.LoadScene(0); } else { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } if (DataHoldGameObject.GetComponent <DataHold>().Level > prefs.level) { prefs.level++; } Destroy(gameObject); } if (acc.x < 0.1f && acc.x > 0f - 0.1f && !fc.inFade && !win && !readyToMove) { if (acc.y < 0.1f && acc.y > 0f - 0.1f) { PlayAudio(StartAudioClip); readyToMove = true; GetComponent <GuiTimer>().run = true; } } if (speedMeter.playerSpeed * 100 <= RigidbodyVariables.slowestSpeed) { rb.drag = RigidbodyVariables.highDrag; } else { rb.drag = RigidbodyVariables.lowDrag; } }