private void attackUpdate(Vector3f orientation, float distance){
        double time = ((double)Time.getTime())/((double)Time.SECOND);
        double timeDecimals = time - (double)((int)time);

        if(timeDecimals < 0.25) {
            canAttack = true;
            material.setTexture(animations.get(4));
        }
        else if(timeDecimals < 0.5)
            material.setTexture(animations.get(5));
        else if(timeDecimals < 0.75){
            material.setTexture(animations.get(4));
            if (canAttack) {
                Vector2f lineStart = new Vector2f(transform.getTranslation().getX(), transform.getTranslation().getZ());
                Vector2f castDirection = new Vector2f(orientation.getX(), orientation.getZ()).rotate((rand.nextFloat() - 0.5f) * SHOT_ANGLE);
                Vector2f lineEnd = lineStart.add(castDirection.mul(SHOOT_DISTANCE));

                Vector2f collisionVector = Game.getLevel().checkIntersection(lineStart, lineEnd, false);

                Vector2f playerIntersect = Game.getLevel().lineIntersectRect(lineStart, lineEnd,
                        new Vector2f(Transform.getCamera().getPos().getX(), Transform.getCamera().getPos().getZ()),
                        new Vector2f(Player.PLAYER_SIZE, Player.PLAYER_SIZE));

                if (playerIntersect != null && (collisionVector == null ||
                        playerIntersect.sub(lineStart).length() < collisionVector.sub(lineStart).length())) {
                    Game.getLevel().damagePlayer(rand.nextInt(DAMAGE_MAX - DAMAGE_MIN));
                }

                canAttack = false;
                state = CHASE;
            }
        }
    }