public void DrawLine() { if (gameObject != null && nextPoint != null) { LineRenderer lineRenderer = gameObject.GetComponent <LineRenderer>(); lineRenderer.positionCount = 2; lineRenderer.SetPosition(0, GetGameobjectPosition()); lineRenderer.SetPosition(1, nextPoint.GetGameobjectPosition()); } }