Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void EnableMovementAndJump(bool enable)
- {
- canMove = enable;
- canJump = enable;
- }
- private void HandleAnimations()
- {
- anim.SetFloat("xVelocity", rb.linearVelocity.x);
- anim.SetFloat("yVelocity", rb.linearVelocity.y);
- anim.SetBool("isGrounded", isGrounded);
- }
- private void HandleInput()
- {
- xInput = Input.GetAxisRaw("Horizontal");
- if (Input.GetKeyDown(KeyCode.Space))
- TryToJump();
- if (Input.GetKeyDown(KeyCode.Mouse0))
- TryToAttack();
- }
- private void TryToAttack()
- {
- if (isGrounded)
- {
- anim.SetTrigger("attack");
- rb.linearVelocity = new Vector2(0, rb.linearVelocity.y);
- }
- }
- private void TryToJump()
- {
- if (isGrounded && canJump)
- rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce);
- }
- private void HandleMovement()
- {
- if(canMove)
- rb.linearVelocity = new Vector2(xInput * moveSpeed, rb.linearVelocity.y);
- }
- private void HandleCollision()
- {
- isGrounded = Physics2D.Raycast(transform.position, Vector2.down, groundCheckDistance, whatIsGround);
- }
Advertisement
Add Comment
Please, Sign In to add comment