private void Move() { float horizontal = input.GetHorizontal(); float vertical = input.GetVertical(); Vector3 direction = new Vector3(horizontal, 0f, vertical);; if (direction != Vector3.zero) { transform.forward = direction; // Calculates the next position the player is going to be next frame Vector3 nextPos = rb.position + (direction.normalized * speed * Time.fixedDeltaTime); if (CanMove(nextPos)) { rb.MovePosition(nextPos); moving = true; animator.SetBool("isWalking", true); } else { moving = false; animator.SetBool("isWalking", false); } } else { moving = false; animator.SetBool("isWalking", false); } }