/// <summary> /// Called once per frame /// </summary> private void Update() { // If enabled the process controls if (_isEnabled) { /* ---- HANDLE ANCHORING ---- */ if (Input.GetButtonDown("Jump") && !isFlying()) { _isAnchored = false; _rigidbody.gravityScale = 0; _collider.isTrigger = true; StartCoroutine(_takeoff()); } else if (_isAbleToLand() && isFlying() && Input.GetButtonDown("Jump")) { // Set the regeneration rate since you are no longer flying _energyManager.setRegenerationRate(anchoredEnergyRegenRate); // Reset all defaults _isAnchored = true; _collider.isTrigger = false; _rigidbody.gravityScale = _originalGravityScale; _rigidbody.velocity = new Vector2(0f, 0f); // Stop flying since you are landing _animator.SetBool("flying", false); } } }