Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Runtime] ClonePath + CurySpline refresh problems
#1
Hi,

I would like to create a clone path at runtime. So far everything works except for the last step: The gameobjects created by clonepath are only refreshed and visible when I click on assigned spline in the scene editor view. I already added refresh methods to both scripts (spline and clonepath), but without any success.

How can I solve this issue?

 

 
Reply
#2
Hi,

A quick shot: If the spline for some reason doesn't have a length calculated, the clone builder won't work. Could you please check that by adding Debug.Log(mySpline.Length) ?




 

 
Reply
#3
The spline got a length higher than 0. Note: I am using prefabs for both ClonePath and CurvySpline.
 
Reply
#4
Are you able to provide an exported package that reproduce this? This would be extremly helpful and wonderful! (please don't include dependencies!).

 
Reply
#5
(11-25-2013, 11:10 AM)'Jake' Wrote: Are you able to provide an exported package that reproduce this? This would be extremly helpful and wonderful! (please don't include dependencies!).

 

 
Not sure if I actually need to. Sorry for the really long silence, but I've been busy with troubleshooting on my own and a lot of other issues. Here is how I proceed from scratch:
-Create a cube, make it a prefab.
-Create empty with SplinePathCloneBuilder, make prefab, add prefab cube to source list.
-Create empty with CurvySpline, make prefab.
-Runtime: Instantiate CloneBuilder prefab and CurvySpline prefab, assign splines, change gap and some vector data, refresh spline and builder.

Note: Spline shows no effect after refresh. Only clicking on the gameobject in scene view at runtime actually makes cubes show up in the scene.


 

I think I got it! If the pathclonebuilder prefab already got some children for whatever reason, the newly computed children are refreshed only given the above circumstances. If the prefab got no children, everything works as expected.
 

 
Reply
#6
I am experiencing the same issue but with SplinePathMeshBuilder. I am generating both the spline and SplinePathMeshBuilder mesh at runtime.

I have tried AutoRefresh on and off, .Refresh(), .RefreshImmediately(), and a number of combinations.

I am just using 2 point splines in my game. The only way to get the mesh to correctly follow the spline is to select the second (last) control point in the Unity Hierarchy list, and then click the Refresh button in the SplinePathMeshBuilder editor interface.

If I just click the first control point and then click refresh, the mesh does not refresh.

 

Okay, a bit more investigating has revealed that CurvySpline is at fault, not SplinePathMeshBuilder.

I removed SplinePathMeshBuilder from my code, just leaving CurvySpline (the actual spline), and I can see the same issue happening with the red spline.

p.s. Can an admin please rename this topic to something shorter? When replying it complains about the topic length, I assume because the forum software did not take the "RE: " prefix into account when limiting the input box length. I can click "Preview Post" and shorten the topic to get around the issue, but it's still a pain.
 
Reply
#7
(01-15-2014, 12:31 PM)'Marty' Wrote: I am just using 2 point splines in my game. The only way to get the mesh to correctly follow the spline is to select the second (last) control point in the Unity Hierarchy list, and then click the Refresh button in the SplinePathMeshBuilder editor interface. 
Just to clarify: With "follow the spline" you mean that you're moving the CPs (e.g. by setting the transform's position) by code, right?



 
Reply
#8
(01-15-2014, 07:51 PM)Jake Wrote: Just to clarify: With "follow the spline" you mean that you're moving the CPs (e.g. by setting the transform's position) by code, right? 

Thanks for the quick reply!

Yup, my code pretty much looks like this:

Code:
CurvySpline spline = CurvySpline.Create();

spline.Interpolation = CurvyInterpolation.Bezier;

CurvySplineSegment startControlPoint = spline.Add();
CurvySplineSegment endControlPoint = spline.Add();

startControlPoint.transform.position = Vector3.zero;
endControlPoint.transform.position = new Vector3(10, 0, 10);

startControlPoint.HandleOut = new Vector3(0, 0, 5);
endControlPoint.HandleIn = new Vector3(-5, 0, 0);

Ignore everything prior to this post because having just used that code in a new scene I think "not refreshing" is inaccurate.

The code above successfully creates a 90 degree curve, but as soon as I select the endControlPoint (CP001) in the editor (paused) view, the bug shows itself - the endControlPoint HandleIn position suddenly moves from (-5, 0, 0) to (-1, 0, 0).

So the bug appears to only happen after pausing the game and selecting the endControlPoint in editor view.
 
Reply
#9
Ok, seems like you actually discovered two problems:

First, try to set FreeHandles=true and set both HandleOut/HandleIn of your CPs manually. What happens is that the editor synchronizes HandleIn/HandleOut when FreeHandles is off. Alternatively, set HandleInPosition/HandleOutPosition (like HandleOut/HandleIn, but using global coordinates). The bug is that HandleOut/HandleIn don't respect FreeHandles now. I'll fix this for the next release, so setting one will change the other immediately when FreeHandles is off.

The second bug is that changing Handles does not trigger a refresh now. A call to spline.Refresh(true,true,false) should do the trick.

Jake
Reply
#10
Thanks Jake, that's solved it!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
Wink Modifying Splines at Runtime artsung 1 7 01-30-2024, 09:40 AM
Last Post: _Aka_
  Is it possible to create a road texture at runtime? artsung 1 4 01-30-2024, 09:30 AM
Last Post: _Aka_
  Cant Generate Meshes At Runtime alms94 5 22 01-26-2024, 11:27 AM
Last Post: _Aka_

Forum Jump: