// private void Update() { if (cachedBody == null) { return; } if (cachedHands == null) { return; } // recovery if (Input.GetButtonDown(jump) && cachedHero.CanRecover()) { cachedHero.RestoreAfterLanding(); } if (isGrabbed) { return; } // movement float input = Input.GetAxis(moveHorizontal); isMoving = Mathf.Abs(input) > Mathf.Epsilon; cachedBody.velocity = new Vector2(input * moveVelocity, cachedBody.velocity.y); // orient if (isMoving) { cachedTransform.localScale = new Vector3(Mathf.Sign(input), 1.0f, 1.0f); } // block if (Input.GetButtonDown(block)) { isBlocking = true; } if (Input.GetButtonUp(block)) { isBlocking = false; } if (Mathf.Abs(cachedHero.stamina) < Mathf.Epsilon) { isBlocking = false; } // jump if (Input.GetButtonDown(jump) && !cachedCollision.InAir()) { cachedBody.velocity = cachedBody.velocity.WithY(jumpVelocity); cachedCollision.SetInAir(true); currentJumps = 0; } if (Input.GetButtonDown(jump) && cachedCollision.InAir() && (currentJumps < maxJumps)) { cachedBody.velocity = cachedBody.velocity.WithY(jumpVelocity); currentJumps++; } // grab if (isBlocking) { cachedHands.Drop(); } else { if (Input.GetButtonDown(grab)) { cachedHands.Grab(); } if (Input.GetButtonUp(grab)) { cachedHands.Drop(throwStrength, throwVertical); } } }