// Use this for initialization
    void Start()
    {
        targetPos = transform.position;

        puskaScript   = GetComponent <BushMechanism>();
        spawnerScript = GetComponent <SpawnBeardPiece>();
        HUDScript     = GetComponent <HUD>();

        animController = GetComponentInChildren <Animator>();
        animController.SetBool("Idle Still", true);
    }
    void Move(Vector3 direction)
    {
        // Rotate player model towards the right direction.
        float angle = Vector3.SignedAngle(transform.GetChild(0).forward, direction, Vector3.up);

        transform.GetChild(0).Rotate(Vector3.up, angle);

        Debug.DrawRay(targetPos, direction * rayDist, Color.blue, 120);

        // If the raycast DIDN'T hit anything
        if (!Physics.Raycast(targetPos, direction, out rayHit, rayDist))
        {
            // Move if there's enough beard left
            if (beardCount > 0)
            {
                spawnerScript.Trigger(direction, transform.position);

                targetPos += direction * distance;
                animController.SetBool("Walk", true);

                HUDScript.UpdateBeard(--beardCount);
            }
            else
            {
                Debug.Log("No moves left");
            }
        }
        else // Raycast hit something.
        {
            if (rayHit.collider.name == "Shack")
            {
                animController.SetBool("End", true);
                doorAnim.Play();
                startTimer = true;
                Debug.Log("u won");
            }
            else if (rayHit.collider.name.Substring(0, 13) == "Ground Growth")
            {
                puskaScript = rayHit.collider.GetComponentInParent <BushMechanism>();
                if (puskaScript.OnkoMarja())
                {
                    animController.SetTrigger("Eat");
                    HUDScript.UpdateBeard(beardCount += 5);
                }
            }
        }
    }