// Update is called once per frame void Update() { if (InputManager.GetButton(shootButtonName) && breakTime <= 0) { Fire(); breakTime = breakBetweenShots; } breakTime = (breakTime <= 0) ? 0 : breakTime - Time.deltaTime; }
public void OnPointerDown() { TimeSpan span = DateTime.Now - lastDownTime; if (span.TotalMilliseconds > 200) { lastDownTime = DateTime.Now; bool down = CrossPlatformInputManager.GetButton(Name); Image img = GetComponent <Image>(); if (down) { CrossPlatformInputManager.SetButtonUp(Name); img.color = Color.white * 0.8f; } else { CrossPlatformInputManager.SetButtonDown(Name); img.color = Color.cyan * 0.7f; } } }
// 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; } }