private void Update() { if (controller.isGrounded) { position.Set(MoveSpeed * Input.GetAxis("Horizontal"), 0, 0); position = transform.TransformDirection(position); if (Input.GetButton("Jump")) { position.y = JumpSpeed; } } position.y -= Gravity * Time.deltaTime; controller.Move(position * Time.deltaTime); //Generic Attack if (Input.GetKeyDown(KeyCode.LeftShift) && sprite.flipX == false) { RightAttackDown.Invoke(); StartCoroutine(delayedEvent()); } if (Input.GetKeyDown(KeyCode.LeftShift) && sprite.flipX) { LeftAttackDown.Invoke(); StartCoroutine(delayedEvent()); } //Movement events if (Input.GetAxis("Horizontal") > 0 || (Input.GetAxis("Horizontal") < 0)) { Moving.Invoke(); } else { NotMoving.Invoke(); } }
private void Update() { HorizontalMove = Input.GetAxis("Horizontal"); VerticalMove = Input.GetAxis("Vertical"); if (HorizontalMove == 0 && VerticalMove == 0) { NotMoving?.Invoke(); _movementController.MoveTime = 0; _movementController.StepTime = 0; if (_isPlayerMoving) { StoppedMoving?.Invoke(); _walkController.StopMove(); _isPlayerMoving = false; } return; } _isPlayerMoving = true; MovePlayer(_movementController.GetPlayerSpeed()); }