// Update is called once per frame void Update() { // Phone Input. if (CrossPlatformInputManager.GetButton(tiltString)) { TiltPhone(); } else if (CrossPlatformInputManager.GetButtonUp(tiltString)) { ResetRotation(); } }
// Update is called once per frame void Update() { if (CrossPlatformInputManager.GetButton(floatString)) { FloatingTriggered(); } else if (CrossPlatformInputManager.GetButtonUp(floatString)) { TurnOffFloating(); } if (isFloating) { float loudness = microphoneInputScript.loudness; characterHeight = playerObj.transform.position.y; AdaptForceFromHeight(characterHeight); print("Loudness: " + loudness); if (playerRigid.velocity.magnitude < 0f) { playerRigid.drag = 15; } else { playerRigid.drag = 5; } // playerRigid.drag = playerRigid.velocity.magnitude < 0f ? 15 : 5; if (playerObj.transform.position.y < 4.5f) { canGoHigher = true; } else { canGoHigher = false; } // You can do this //canGoHigher = playerObj.transform.position.y < 4.5f if (canGoHigher && canGoHighterCooldown <= 0 && loudness > 0.1f) { float forceToAdd = loudness * forceModifier; canGoHigher = false; canGoHighterCooldown = cooldownLength; playerRigid.AddForce(playerObj.transform.forward.x * forceToAdd / 2, forceToAdd, playerObj.transform.forward.z * forceToAdd / 2); } // characterScript.HandleAirborneMovement(); canGoHighterCooldown--; timer -= Time.deltaTime; tempTimerText.text = timer.ToString(); if (timer <= 0) { TurnOffFloating(); tempTimerText.text = "Time's Up"; isCoolingDown = true; } }//isfloating //timers to cooldown mechanic if (isCoolingDown) { isFloating = false; scriptCooldown -= Time.deltaTime; tempTimerText.text = "Cooldown: " + scriptCooldown + "s"; TurnOffFloating(); // floatButton.enabled = false; } if (scriptCooldown <= 0) { isCoolingDown = false; scriptCooldown = scriptCooldownLength; tempTimerText.text = ""; Reset(); //floatButton.enabled = true; } }