IEnumerator ModifyAngle()
 {
     while (true)
     {
         rotCalc.rectRad  = rectRad;
         rotCalc.rectRadZ = rectRadZ;
         rotCalc.yMod     = yMod;
         rotCalc.MakeCalculations(transform, modelToRotate);
         rotCalc.MakeCalculationsZ(transform, modelToRotate);
         if (debugMode)
         {
             rotCalc.DebugLines();
         }
         yield return(new WaitForSeconds(0.01f));
     }
 }
    void Update()
    {
        timeBetSteps = freq / agent.velocity.magnitude;
        if (stepIndex == poolSize)
        {
            stepIndex = 0;
        }
        if (agent.velocity.magnitude > 0)
        {
            stepTimer += Time.deltaTime;
            if (stepTimer > timeBetSteps)
            {
                stepTimer = 0;
                Ray        ray = new Ray(stepPos.position, -Vector3.up);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, 2f, groundMask))
                {
                    steps [stepIndex].position = hit.point + Vector3.up * 2.0f;

                    steps[stepIndex].rotation = Vec3Mathf.GetDir(transform.position, steps[stepIndex].position);
                    float corr = Random.Range(-0.3f, 0.3f);
                    steps[stepIndex].position = new Vector3(
                        steps[stepIndex].position.x + corr,
                        steps[stepIndex].position.y,
                        steps[stepIndex].position.z
                        );

                    rotCalc.MakeCalculations(steps[stepIndex], steps[stepIndex]);
                    rotCalc.MakeCalculationsZ(steps[stepIndex], steps[stepIndex]);

                    place.Place(steps[stepIndex]);
                    steps [stepIndex].gameObject.SetActive(true);
                    stepIndex++;
                }
            }
        }
    }