void UpdateSwordHand() { float deltaMovement = Input.GetAxis("mouse_horizontal") * mouseSensitivity * Time.deltaTime; bool wantsToMoveSword = Mathf.Abs(deltaMovement) > 0.001f; if (wantsToMoveSword) { if (punchIsPossible) { waitingForSwordStop = false; if (!swordIsMoving) { sword.BroadcastMessage("OnSwordMovementStarted"); swordIsMoving = true; } float newSwordDirection = Mathf.Sign(deltaMovement); if (newSwordDirection != currentSwordDirection) { sword.BroadcastMessage("OnSwordChangedMoveDirection"); currentSwordDirection = newSwordDirection; } swordHandPosition += deltaMovement; swordHandPosition = Mathf.Clamp(swordHandPosition, 0, 1); SetSwordHandPosition(swordHandPosition); } } else if (swordIsMoving) { if (waitingForSwordStop) { if (Time.time >= timeForSwordStop) { StopSwordMovement(); } } else { timeForSwordStop = Time.time + 0.3f; waitingForSwordStop = true; } } }