05-04-2016, 12:24 PM
(This post was last modified: 05-04-2016, 01:58 PM by BlackRainbowFT.)
Hi!
I'm creating a vertical road using the generator (shape extrusion) and feeding it a a randomly generated set of control points.
The road itself is completely flat (localPosition.z is always = 0).
About 50% of the time the generated mesh is perfect (it took me a while to avoid overlapping triangles and getting z fighting) and the remaining times the road insists on behaving unexpectedly.
It all depends on what I select as Orientation under my Curvy Spline general settings:
- if I select "Static": some parts of the mesh will be flipped 180° (this happens 100% of the time) (picture 1).
- If I select "Dynamic": sometimes (~50%) I get what I want (picture 2) and sometimes it starts twisting around (picture 3) and when it does it's not like the road is always perpendicular to the x axis... it may start correctly aligned and then corkscrew around the Y axis...
this is the main loop that generates the spline:
any ideas?
Thank you for your help!
I'm creating a vertical road using the generator (shape extrusion) and feeding it a a randomly generated set of control points.
The road itself is completely flat (localPosition.z is always = 0).
About 50% of the time the generated mesh is perfect (it took me a while to avoid overlapping triangles and getting z fighting) and the remaining times the road insists on behaving unexpectedly.
It all depends on what I select as Orientation under my Curvy Spline general settings:
- if I select "Static": some parts of the mesh will be flipped 180° (this happens 100% of the time) (picture 1).
- If I select "Dynamic": sometimes (~50%) I get what I want (picture 2) and sometimes it starts twisting around (picture 3) and when it does it's not like the road is always perpendicular to the x axis... it may start correctly aligned and then corkscrew around the Y axis...
this is the main loop that generates the spline:
Code:
CurvySpline CS = RoadSpline.GetComponent<CurvySpline>();
for (int i = 0; i < numberOfCPs; i++)
{
CurvySplineSegment CSS_Last = CS.ControlPoints[CS.ControlPoints.Count - 1];
CurvySplineSegment CSS = CS.InsertAfter(CSS_Last);
float xPosition = Random.Range(-maxHorizontalWidth, maxHorizontalWidth);
float yPosition = CSS_Last.localPosition.y + verticalSpacingBetweenCPs;
CSS.localPosition = new Vector3(xPosition, yPosition , 0);
CSS.localRotation = CSS_Last.localRotation; //this doesn't help either
}
any ideas?
Thank you for your help!