public void ManageJumping() { groundedRememberTimer -= Time.deltaTime; if (groundedChecker.IsGrounded()) { groundedRememberTimer = groundedRemember; } jumpPressedRememberTimer -= Time.deltaTime; if (Input.GetButtonDown("Jump")) { jumpPressedRememberTimer = jumpPressedRemember; } if (groundedRememberTimer > 0f && jumpPressedRememberTimer > 0f) { jumpPressedRememberTimer = 0f; groundedRememberTimer = 0f; rb.velocity = new Vector2(rb.velocity.x, stats.jumpHeight); //AudioManager.instance.PlaySound("Jump"); } if (Input.GetButtonUp("Jump")) { if (rb.velocity.y > 0f) { rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * cutOfJumpHeight); } } }
public void ManageJumping() { groundedRememberTimer -= Time.deltaTime; if (groundedChecker.IsGrounded() || wallClimbing.IsSliding) { groundedRememberTimer = groundedRemember; } jumpPressedRememberTimer -= Time.deltaTime; if (isWallJumping) { rb.velocity = new Vector2(wallJumpDirection * stats.jumpHeight * 0.6f, stats.jumpHeight * 0.6f); } else { if (Input.GetButtonDown("Jump")) { jumpPressedRememberTimer = jumpPressedRemember; } if (groundedRememberTimer > 0f && jumpPressedRememberTimer > 0f) { jumpPressedRememberTimer = 0f; groundedRememberTimer = 0f; isWallJumping = isWallJumping || wallClimbing.IsSliding; if (isWallJumping) { playerState.IsAbleToMove = false; wallJumpDirection = Input.GetAxisRaw("Horizontal") * -1; Invoke(nameof(FinishWallJump), wallJumpTime); } else { rb.velocity = new Vector2(rb.velocity.x, stats.jumpHeight); } AudioManager.instance.PlaySound("Jump"); } if (Input.GetButtonUp("Jump")) { if (rb.velocity.y > 0f) { rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * cutOfJumpHeight); } } } }
public void ManageWallClimbing(float input) { isTouchingFront = wallCollisionChecker.IsTouchingWall(); if (isTouchingFront && !groundedChecking.IsGrounded() && input != 0) { IsSliding = true; } else { IsSliding = false; } anim.SetBool(IsSlidingRight, IsSliding && wallCollisionChecker.GetCollisionDirection() == CollisionDirection.Right); anim.SetBool(IsSlidingLeft, IsSliding && wallCollisionChecker.GetCollisionDirection() == CollisionDirection.Left); if (IsSliding) { rb.velocity = new Vector2(rb.velocity.x, Mathf.Clamp(rb.velocity.y, -slidingSpeed, float.MaxValue)); } }
private void Update() { if (dashed) { if (Mathf.Abs(transform.position.x - lastImageXPos) > distanceBetweenImages) { PlayerAfterImagePool.Instance.GetFromPool(); lastImageXPos = transform.position.x; } } if (groundedChecker.IsGrounded() || wallCollisionChecker.IsTouchingWall() && dashed == false) { RefillDashes(); } if (rememberTimer > 0f && Mathf.Abs(rb.velocity.x) > 0f) { rememberTimer = 0f; StartCoroutine(DashCoroutine()); } rememberTimer -= Time.deltaTime; }