void OnJump(InputAction.CallbackContext context) { if (jumping.Jump()) { foreach (var action in onJumpActions) { action(); } } }
void Update() { var horizontalInput = Input.GetAxis("Horizontal"); // player movement // left player movement if (Mathf.Abs(horizontalInput) > 0.0f || moveRight || moveLeft) //check for keyboard movement, or check if eventTriggers were pressed. { if (horizontalInput > 0.0f || moveRight == true) //if Right eventTrigger pressed, or if player trying to move right { if (moveRight == true) { horizontalInput = 1; } if (controller.IsGrounded || wasRunningBeforeJump) { wasRunningBeforeJump = true; controller.Move(horizontalInput); } else { controller.Move(horizontalInput * .5f); } facingRight = true; } if (horizontalInput < 0.0f || moveLeft == true) //if Left event trigger pressed, or if player trying to move left { if (moveLeft == true) { horizontalInput = -1; } if (controller.IsGrounded || wasRunningBeforeJump) { wasRunningBeforeJump = true; controller.Move(horizontalInput); } else { controller.Move(horizontalInput * .5f); } facingRight = false; } if (controller.IsGrounded) //no running animation unless player grounded. { RunAnimation(); } } flipXAxis(weaponTransform); //flipXAxis (firePoint); //idle if (controller.Velocity == Vector2.zero && !touchScreenMode) //if player isn't moving and touchScreenMode isnt active. { IdleAnimation(); } if (!moveLeft && !moveRight && touchScreenMode && controller.IsGrounded) { rb.velocity = Vector2.zero; IdleAnimation(); } // jump if (Input.GetKeyDown(KeyCode.UpArrow) || jumping) { if (wasRunningBeforeJump) { //audioSourcePlayer.PlayOneShot(audioPlayerJump, 1F); //Jump Sound jumper.Jump(); } else if (!wasRunningBeforeJump) { IdleAnimation(); //audioSourcePlayer.PlayOneShot(audioPlayerJump, 1F); //Jump Sound jumper.Jump(); } } // shoot if (Input.GetKeyDown(KeyCode.Space)) { //Fire(); } }