Example #1
0
    /// <summary>
    /// Draws the bezier ray.
    /// </summary>
    private void DrawBezierRay()
    {
        bezierRay.RemoveCurves();

        if (targetInteractable == null)
        {
            return;
        }

        Vector3 pointOnLine = NearestPointOnLine(primaryHand.transform.position, primaryHand.transform.forward,
                                                 targetInteractable.transform.position);
        Vector3 dir   = targetInteractable.transform.position - pointOnLine;
        float   dist1 = dir.magnitude;
        float   dist2 = Vector3.Distance(primaryHand.transform.position, pointOnLine);

        Vector3[] bezierPoints = new Vector3[4];
        bezierPoints[0] = primaryHand.transform.position;
        bezierPoints[1] = primaryHand.transform.position + dist2 * (1f / 3f) * primaryHand.transform.forward.normalized;
        bezierPoints[2] = primaryHand.transform.position + dist1 * (2f / 3f) * dir.normalized +
                          dist2 * (2f / 3f) * primaryHand.transform.forward.normalized;
        bezierPoints[3] = targetInteractable.transform.position;

        bezierRay.AddCurve(bezierPoints, Color.red, Color.red, 0.005f, 0.0025f);
    }
Example #2
0
 public void RemoveCurves()
 {
     lines.RemoveCurves();
     _curveCount = -1;
 }