// Update is called once per frame void Update() { if (_input.GetButton("UseItem1")) { if (!_itemPressed) { _itemPressed = true; HealthPotionItem.Use(_status); ItemGUI.Instance.UpdateItems(); } } else if (_input.GetButton("UseItem2")) { if (!_itemPressed) { _itemPressed = true; MagicPotionItem.Use(_status); ItemGUI.Instance.UpdateItems(); } } else { _itemPressed = false; } }
void Update() { // Store the input axes. h = Input.GetAxis("Horizontal"); v = Input.GetAxis("Vertical"); // Set the input axes on the Animator Controller. anim.SetFloat(hFloat, h, 0.1f, Time.deltaTime); anim.SetFloat(vFloat, v, 0.1f, Time.deltaTime); // Toggle sprint by input. sprint = Input.GetButton(sprintButton); // Set the correct camera FOV for sprint mode. if (IsSprinting()) { changedFOV = true; camScript.SetFOV(sprintFOV); } else if (changedFOV) { camScript.ResetFOV(); changedFOV = false; } // Set the grounded test on the Animator Controller. anim.SetBool(groundedBool, IsGrounded()); }
// Update is used to set features regardless the active behaviour. void Update() { // Activate/deactivate aim by input. if (Input.GetAxisRaw(aimButton) != 0 && !aim) { StartCoroutine(ToggleAimOn()); } else if (aim && Input.GetAxisRaw(aimButton) == 0) { StartCoroutine(ToggleAimOff()); } // No sprinting while aiming. canSprint = !aim; // Toggle camera aim position left or right, switching shoulders. if (aim && Input.GetButtonDown(shoulderButton)) { aimCamOffset.x = aimCamOffset.x * (-1); aimPivotOffset.x = aimPivotOffset.x * (-1); } // Set aim boolean on the Animator Controller. behaviourManager.GetAnim.SetBool(aimBool, aim); // Weapon control if (weapon != null) { if (aim) { weapon.weaponAim(true); } else { weapon.weaponAim(false); } if (Input.GetButton("Fire1")) { weapon.Fire(); } } }