/// <summary> /// Callback to draw gizmos that are pickable and always drawn. /// </summary> private void OnDrawGizmos() { if (points.Length > 0) { m_controlPoints = new Vector3[points.Length]; for (int i = 0; i < m_controlPoints.Length; i++) { if (points[i]) { m_controlPoints[i] = points[i].transform.position; } } if (isUseBezier && m_controlPoints.Length > 2) { for (float i = 0; i <= 1; i += 0.1f) { m_drawPos = GraphicMath.BezierToPoint(i, m_controlPoints); Gizmos.DrawSphere(m_drawPos, 0.25f); } } else { if (m_controlPoints.Length >= 2) { for (int i = 0; i < m_controlPoints.Length - 1; i++) { Gizmos.DrawLine(m_controlPoints[i], m_controlPoints[i + 1]); } } } } }
private void _UpdateComplete() { if (!isCompletePath) { if (m_CurrentPath.isUseBezier) { if (GraphicMath.BezierToPoint(tempDelta, route) == route[route.Length - 1]) { isCompletePath = true; } } else { if (GraphicMath.MoveToPoint(tempDelta, m_CurrentPoint, m_NextPoint, true, false) == m_NextPoint) // && m_NextPoint == m_CurrentPath.GetRoute()[m_CurrentPath.GetRoute().Length - 1]) { isCompletePath = true; } } } }
public Vector2 GetTargetPosition(float dt) { tempDelta = dt; if (!isMoveComplete) { // Debug.Log("false"); if (m_CurrentPath.isUseBezier) { return(GraphicMath.BezierToPoint(dt, route)); } else { return(GraphicMath.MoveToPoint(dt, m_CurrentPoint, m_NextPoint, true, false)); } } else { // Debug.Log(dt); // Debug.Log("complete"); return(m_Paths[m_Paths.Length - 1].GetRoute()[m_Paths[m_Paths.Length - 1].GetRoute().Length - 1]); } }