Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug in Spline makes unity freeze
#11
Yeah, nice. But I need the actual settings (from the Inspector, so UV settings, Extrusion mode etc...)...
Reply
#12
(01-12-2014, 11:31 AM)'Jake' Wrote: Yeah, nice. But I need the actual settings (from the Inspector, so UV settings, Extrusion mode etc...)...


 
I created a DynamicPath obj which has a component of Curvy Spline.
This is the set up.
http://oi44.tinypic.com/2z670if.jpg

In this picture I have a high amount of splines (each yellow dot is a dot in the spline)
http://oi41.tinypic.com/2a7hr0i.jpg

As soon a dot is being created, I assign a CurvyMeshPath and only at the end of the drawing (when the player starts the game) I add a mesh collider.


I have this MakeAPoint function which is quite long, it also gives stacks a location and info about every point (for an Undo button).



Code:
void MakeAPoint()
{
if (cut && !afterCut) //cut point
{
afterCut = true;
cut = false;
wasCut = true;
CurvySpline newCS = CurvySpline.Create();
newCS.name = "DynamicPath" + index;
index++;
newCS.tag = "Track"; //Delete this track also
newCS.InitialUpVector = CurvyInitialUpDefinition.ControlPoint;
current_spline = newCS;
CreateMeshBuilder();
splineStack.Push(current_spline);
}
else if (afterCut)
{
cutButton.SetActive(true);
afterCut = false;
}

point = current_spline.Add(newDotPosition);
Transform dot = point[0].transform;
segmentStack.Push(point[0].gameObject);
dot.tag = "Track";
CreateTempPoint();

if (first) //First point
{
first = false;
second = true;
firstDot = dot.position;
CreateMeshBuilder();
splineStack.Push(current_spline);
}
else if(second) //Second point
{
if (heightChanged)
{
heightChanged = false;
dirVector = newDotPosition - lastDotPosition; //This is the direction vector
dirVector.y = 0;

CurvySplineSegment css = current_spline.PreviousControlPoint(point[0]);
point[0] = current_spline.Add(true, css);
css.transform.position = lastDotPosition + dirVector * 0.2f;
dot = point[0].transform;
dot.tag = "Track";
}

second = false;
secondDot = newDotPosition;
hideButtons.SetActive(true);
cutButton.SetActive(true);
}

AllowedDraw();
lastHeight = currentHeight;
noClick.SetActive(true);
lastDirVector = dirVector;
lastDotPosition = newDotPosition;
pointsLinkedList.AddLast(newDotPosition);
toggleLinkedList.AddLast(currentToggle);
heightsLinkedList.AddLast(currentHeight);
distancesStack.Push(cur_Distance);
dirVectorsStack.Push(dirVector);
cuttedPointStack.Push(wasCut);
lastPointExists = true;
wasCut = false; //important here
undoCut = false; //important here
}


This is the code for the CurvyMeshPath creation:


Code:
void CreateMeshBuilder()
{
meshBuilder = SplinePathMeshBuilder.Create();
meshBuilder.tag = "MeshTrack";
meshBuilder.name = "CurvyMeshPath";
meshBuilder.Spline = current_spline;
meshBuilder.UV = SplinePathMeshBuilder.MeshUV.Absolute;
meshBuilder.CapShape = SplinePathMeshBuilder.MeshCapShape.Rectangle;
meshBuilder.Extrusion = SplinePathMeshBuilder.MeshExtrusion.FixedDistance;
meshBuilder.ExtrusionParameter = 1;
meshBuilder.CapHeight = 0.1f;
meshBuilder.CapWidth = 2;
meshBuilder.GetComponent<MeshRenderer>;().material = roadMat;
}

I currently can't show the CurvyMeshPath in the inspector, since every time I click on the object Unity simply crashes from unknown reason, I'll check it later and will post an image, if you need it.
 
Reply
#13
Ok, on a first look I see nothing weird in your code. Don't having a scene to test with makes it hard to find the bug, but let's try to nail it down. We better switch over to mail and present the results here later.

Jake
Reply
#14
Ok, for everyone having the same issue with the SplinePathMeshBuilder, here's a fix:

Open CurvySpline.cs and locate the method DistanceToTF (float distance) and insert to the following before anything else in the method's body:



Code:
if (Length > 0 && distance >= Length)
return 1;

Jake

 

 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Odd behavior when drawing spline ricke 9 12 11-28-2022, 10:34 AM
Last Post: _Aka_
  Input Spline Shapes from Prefabs destroys graph tairoark 5 6 11-24-2022, 05:08 PM
Last Post: _Aka_
  Scale Deform Mesh Along Spline? / aligning colliders MamasToast 9 61 10-31-2022, 03:44 AM
Last Post: tairoark
  Gap between spline mesh segments Beaver_Boy 13 66 10-24-2022, 09:37 AM
Last Post: dromo

Forum Jump: