Question by
maciekfreak · Mar 31, 2016 at 05:39 PM ·
offsetlinesbeziervectrosity
Offset curve line Vectrosity
I'm trying to draw lines with offset to main line like on attachment.
I have problems with my code. It generating crosses on the lines if curve is small. (attachment)
Maybe someone can help me with this code or know any good algorithm to generate curved lines with offset
// LEFT SIDE OF MAIN LINE
int numberOfLines = 10;
float offset = 10f;
lastLinePoints = outerPoints; // outerPoint = Points from Main Line
for(int i = 0; i < numberOfLines; i++)
{
List<Vector3> tempPoints = new List<Vector3> ();
for (int k = 0; k < lastLinePoints.Count; k++) {
if (k + 1 < lastLinePoints.Count) {
Vector3 direction = lastLinePoints [k + 1] - lastLinePoints [k];
// up direction:
Vector3 up = new Vector3(0.0f, 1.0f, 0.0f);
// find right vector:
Vector3 right = Vector3.Cross(direction.normalized, up.normalized);
Vector3 newPoint = lastLinePoints [k] + (right * offset);
tempPoints.Add (newPoint);
}
}
VectorLine lineTemp = new VectorLine ("lineCurved", tempPoints, 120f / _camera2DObject.GetComponent<Camera> ().orthographicSize, LineType.Continuous);
lineTemp.Draw3D ();
lastLinePoints = tempPoints;
}
screen-shot-2016-03-31-at-193026.png
(116.1 kB)
screen-shot-2016-03-31-at-201018.png
(25.6 kB)
Comment
Answer by wandersonjose75 · Mar 18, 2021 at 06:09 PM
I have the same problem, did you find a solution?
Your answer
![](https://koobas.hobune.stream/wayback/20220612073938im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Offset value not responsive in secondary texture 2 Answers
Change RectTransform anchors and offsets : works in editor, but not in build, why ? 0 Answers
Object following a bezier-curve moves in wrong direction 0 Answers
Lighting Creating Lines? 0 Answers
Strange Vertical offset from origin using TextMesh 0 Answers