- Home /
Question by
ratchetunity · Apr 03, 2019 at 01:23 PM ·
rendererlinerendererlinecurvebezier
Bezier curver using LineRenderer
Hi!
I'm trying to make a bezier curve between two GameObjects using Unity's LineRenderer, but I'm stuck. Here is the code I'm using at the moment:
public GameObject source;
public GameObject target;
private Vector3[] lineVertexPositions;
private LineRenderer lineRenderer;
void Start()
{
lineRenderer = GetComponent<LineRenderer>();
lineRenderer.positionCount = 3;
SetVertexPositios();
for (int i = 0; i < lineRenderer.positionCount; i++)
{
lineRenderer.SetPosition(i, lineVertexPositions[i]);
}
}
void SetVertexPositios ()
{
lineVertexPositions[0] = source.transform.position;
lineVertexPositions[1] = source.transform.position - target.transform.position;
lineVertexPositions[2] = source.transform.position;
}
Comment