IEnumerator FlyAroundPointSafety() { Vector3 startPos = transform.position; float condTime = 0.0f; float angle = Vec3Mathf.GetAngle(transform.position, agent.destination); //Debug.Log(angle); agent.SetDestination(destination = Vec3Mathf.GetCirclePoint(startPos, angle, rad)); while (true) { safetyWalkTime += 0.01f; condTime += 0.01f;//Time.deltaTime; if (agent.remainingDistance < remDist) { angle += anglePlus; destination = Vec3Mathf.GetCirclePoint(startPos, angle, rad); agent.SetDestination(destination); //Debug.Log("Добавляю угол:" + anglePlus); } if (condTime >= 5.0f) { ChangeCondition(Condition.Safety, "FlyAroundPointSafety", "Safety"); } if (fow.visibleTargets.Count > 0) { isEnemySpotted = true; visibleTarget = fow.visibleTargets[0]; ChangeCondition(Condition.Alarm, "FlyAroundPointSafety", "Alarm"); } //if(safetyWalkTime > 15.0f) //{ // ChangeCondition(Condition.Secure, "FlyAroundPointSafety", "GoBackToTheSpot"); //} Debug.DrawLine(startPos, agent.destination, Color.red); yield return(new WaitForSeconds(0.01f)); } }
public void Run(Vector3 start, Vector3 target) { startPos = start; targPos = target; graphLength = (Vector3.Distance(startPos, targPos) / rad) - limit; //Debug.Log(graphLength); if (graphLength >= 1) { vec3points = new Vector3[(int)graphLength]; } else { vec3points = new Vector3[1]; } angle = Vec3Mathf.GetAngle(start, target); //Debug.Log(angle); //Debug.Log("start: "+start +"angle: "+ target); CalcGraph(); if (graphLength < 5) { rar = 1; } }