void Update() { directionalInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); if (dashAfter_WallSlideTime > 0) { dashAfter_WallSlideTime -= Time.deltaTime; } float rot = Quaternion.Euler(0, 0, Math2D.LookAt2D(playerTr.position, graspTr.position)).eulerAngles.z; rot = rot >= 180 ? rot - 180 : rot + 180; rot = (360 - (rot)) / 360; animator.SetFloat("aim", rot); if (animator.GetBool("isHanging") || animator.GetBool("isShoting")) { if (rot > 0.625f) { playerRenderer.flipX = true; } else { playerRenderer.flipX = false; } } if (hookCtrl.state == HookState.Hooked) { if (hookCtrl.isMax) { if ((controller.collisions.below || controller.CheckGround(0.1f)) && Math2D.Sign(transform.position.x - hookCtrl.chainEnd.position.x) == Math2D.Sign(directionalInput.x)) { if (hookCtrl.hookedTr.CompareTag("HookEvent")) { if (!isHookEventing) { isHookEventing = true; hookeEventObject = hookCtrl.hookedTr.GetComponent <InteractableObject>(); } velocity.x = 0; hookeEventObject.Interaction(); if (hookeEventObject.isDone) { ResetRope(); } Interact(); return; } else { if (Input.GetKeyDown(KeyCode.Space)) { OnJumpInputDown(); } else if (Input.GetKeyUp(KeyCode.Space) && !isDashing) { if (velocity.y > minJumpVelocity) { velocity.y = minJumpVelocity; } } if (isDashing) { dashTime -= Time.deltaTime; if (dashTime <= 0 || ((!controller.collisions.aboveThroughPlatform && (dashDir.x > 0 && controller.collisions.right) || (dashDir.x < 0 && controller.collisions.left) || (dashDir.y > 0 && controller.collisions.above)) || (dashDir.y < 0 && controller.collisions.below))) { isDashing = false; velocity = Vector3.zero; } } CalculateVelocity(directionalInput.x); HandleWallSliding(directionalInput); velocity.x = 0; controller.Move(velocity * Time.deltaTime, directionalInput, false); Interact(); return; } } else { isHookEventing = false; } if (!isSwing && !(controller.collisions.below || controller.CheckGround(0.1f))) { canMove = false; rb2D.bodyType = RigidbodyType2D.Dynamic; isSwing = true; animator.SetBool("isShoting", false); animator.SetBool("isHanging", true); } } else if (controller.collisions.below || controller.CheckGround(0.1f)) { SwingEnd(); } } if (canMove) { Movement(); } Interact(); }