Posts: 5
Threads: 2
Joined: Nov 2013
11-21-2013, 02:51 PM
(This post was last modified: 01-15-2014, 07:08 PM by Jake.)
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?
Posts: 690
Threads: 71
Joined: Jan 2015
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) ?
Posts: 5
Threads: 2
Joined: Nov 2013
The spline got a length higher than 0. Note: I am using prefabs for both ClonePath and CurvySpline.
Posts: 690
Threads: 71
Joined: Jan 2015
Are you able to provide an exported package that reproduce this? This would be extremly helpful and wonderful! (please don't include dependencies!).
Posts: 5
Threads: 2
Joined: Nov 2013
12-14-2013, 03:43 PM
(This post was last modified: 12-14-2013, 04:36 PM by Blackdart.)
(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.
Posts: 3
Threads: 0
Joined: Jan 2014
01-15-2014, 12:31 PM
(This post was last modified: 01-15-2014, 01:03 PM by benisrob.)
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.
Posts: 690
Threads: 71
Joined: Jan 2015
(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?
Posts: 3
Threads: 0
Joined: Jan 2014
01-16-2014, 02:29 PM
(This post was last modified: 01-16-2014, 02:30 PM by benisrob.)
(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.
Posts: 690
Threads: 71
Joined: Jan 2015
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
Posts: 3
Threads: 0
Joined: Jan 2014
Thanks Jake, that's solved it!
|