//generate a new point toward the given point Vector3 ReachPoint(Vector3 anchor, Vector3 target, Vector3 center) { //this will return an angle, but we cannot know if that angle is to add or subtract from the direction... float curve = Support.AngleBetweenVector2(new Vector2(anchor.x, anchor.z), new Vector2(target.x, target.z), new Vector2(center.x, center.z)); if (Math.Abs(curve) > maxAngleD) { curve = maxAngleD; } //...so we test both... float direction1 = direction + curve; //the first choosed direction float direction2 = direction - curve; //opposite direction, considering the turn Vector3 point1 = Support.MovePoint(center, direction1, segmentLen); Vector3 point2 = Support.MovePoint(center, direction2, segmentLen); ///..and we see wich one is the correct one (nearest to the point we want to reach) if (Vector3.Distance(point1, target) < Vector3.Distance(point2, target)) { direction = direction1; //points.Add(point1); directions.Add(direction); return(point1); } else { direction = direction2; directions.Add(direction); //points.Add(point2); return(point2); } }