Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Curvy 2 - the ultimate spline solution

Discussion in 'Assets and Asset Store' started by Jake-L, Sep 29, 2015.

  1. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    I could have sworn i replied here... anyway, thanks a lot Jake! Everything works perfectly and i made a little path for a google cardboard app very quickly and its already compiled and sent to the client!
    Thanks again.
     
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Thanks. I ended up using the event handler approach, but I'm glad I can still do it the old way as well.
     
  3. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Hello, I have this Spline creator and I surely is the BEST and most AMAZING asset and with lots of possible options as shown on the many example scenes that are really helpful and useful

    Also there are some good video tutorials and all the web full documentation available only online, I would like if it would be possible to have also a PDF manual

    Thanks very much for making this awesome asset and so powerful and well done

    Please, I want to ask where is the demo scene shown first on the trailer video?

    I mean this one shown here in the screenshot.
     

    Attached Files:

  4. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Unfortunately this isn't possible!

    The scene used in the trailer isn't completly done. Once it is we will see how we share this with our customers. Most likely as a separate download due to it's size.

    Best regards
     
  5. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Thanks very much for your fast answer and for knowing that the trailer demo is still in development. I want to say that I like very much that for making the scenes of the examples is taken really much detail and precision to make them, and are not simple and plain, this is very good.
     
  6. pstudio

    pstudio

    Joined:
    Apr 20, 2014
    Posts:
    12
    Bought this recently and just wanna check. Am I the only one to get the messages that you "Can't destroy Transform component of 'CP00xx'..." and that "Some objects were not cleaned up when closing the scene..." for all the demo scenes that comes with the package?
    Heck, I get the same errors if just create an empty scene and add a spline.
     
  7. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    You're the 2nd one, actually, and we're already working on this issue. What Unity Version do you use?
     
  8. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    I'm curious if it's possible to do something like this in Curvy?

    I have a sidewalk made from tiled stones that appears and reappears along an elevated long road. The sidewalk UV's have to be mapped to the shape. In Blender I would simply use a boolean modifier to delete the mesh on the other side of the road in order to preserve the UV's.

    Is there any way I could get the same result with Curvy? The actual shape is far more complicated naturally, I made a simple to understand example.

    Here might be some solutions:

    - Model everything by hand and forget about curves ( I don't like this option at all)

    - Using stencil or depth mask shaders to act like a fake boolean ( Tricky and not fun with using other peoples shaders - unexpected results are almost guaranteed)

    - Live with having very bad UV's, and wonky textures

    - Some other way that I'm too stupid to see myself


    The UV's have to follow the sidewalk. (blender example)


    But the sidewalk can't be seen beyond the elevated road. (blender example)

    I apologize if I derail the thread slightly but a feature that would aid in the above situation, might prove useful to other people than myself.
     
  9. pstudio

    pstudio

    Joined:
    Apr 20, 2014
    Posts:
    12
    I was using 5.2.0 but I tried updating to the latest 5.2.3 to see if it would help. It didn't and I still get the error messages with a clean project where I have only imported Curvy.
     
  10. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    I'm not sure I understand what you're asking for right. I take it orange bit is the part you want to do with Curvy, and you want to completely cut everything outside of blue volume from that extrusion?
     
  11. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    You understood my issue perfectly.

    I just purchased Curvy so
    Both the orange and blue parts are shaped by curves. The problem is that the orange texture has to tile along the curve, but the shape ends abruptly in a wall.

    The UV tiling is the problem.
     
  12. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    I don't think I understand the UV tiling issue, but yeah, boolean operations like those are not supported by Curvy at the moment.

    I don't think a good CSG implementation ever existed for Unity, every single package I saw that has claimed to allow operations like those had numerous issues. But if you'll happen to find one, using it to achieve the desired result will be easy, since Curvy extrusions are just normal meshes you can easily plug into any entity doing actual boolean cutting.

    Some possible workarounds:

    • Use a Curvy extrusion with a high split frequency, which will divide the path into many meshes. Then you can leverage occlusion culling (or directly discard unneeded mesh objects using a simple bounds check).
    • If you have basic shapes like on the images above (that sample resembles something like a leaf pile prop for roadside placement), then authoring them manually and then using CG Spot placement for those props will be an easy way to populate the road.
    • Generators support mesh export, so you can probably export both shapes to OBJ and perform the boolean cutting there once you are committed to a certain shape.
     
  13. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Thanks for the hints. I really appreciate it.

    It's really quite simple, Imagine a sidewalk with distinct rocks in the outer edge for instance. If I can make such a tiling shape without modifying the geometry, then it would be great.
     
  14. mbcauley

    mbcauley

    Joined:
    Jun 1, 2013
    Posts:
    36
    Hey there,

    I am trying to implement Curvy into my VR game as a path modifier at runtime. Basically, each time the player picks a new direction there is a path generated using Curvy. The paths seem to be working well but I am also generating a tube mesh to go along with it and it seems to be slowing me down quite a bit.

    Each time I call the path generator it adds 38ms delay. You can see the attached screenshot below. The delay also occurs when I Clear() the spline as well as you can see by the spike later on in the graph as well.

    Is there something I can do to optimize this? I am trying to keep my frame rate very consistent.

    Thank you!
    Mac

     
  15. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Hi All,

    Is it possible to find the World position of a spot on the Spline? (i.e. can I pass a float which represents my initial position into a function and get a vector3 out)?

    Cheers,
    Colton
     
  16. mbcauley

    mbcauley

    Joined:
    Jun 1, 2013
    Posts:
    36
    Yes, you can get the world position by using the Interpolate (for a TF float) or InterpolateByDistance methods on your spline like this:

    float myTF = 0.5f;
    Vector3 posFromSpline = mySpline.Interpolate(myTF);

    or if you want to use the distance instead:

    float myDistance = 10.5f;
    Vector3 posFromSpline = mySpline.InterpolateByDistance(myDistance);

    Hope that helps!
     
  17. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Thanks for the help Mac,

    I think that is what I am looking for, however, I am still having a small issue with my enemy spawning. I am using object pooling and enabling/disabling objects when they die. The problem is when I spawn them again (enable them) I put them on a random point on the spline and give them a random velocity etc. Sometimes I can see the enemy flash in a different position before they start following the spline. I thought setting there initial position with your above comment would fix the issue but it did not. Any other suggestions?

    Cheers,
    Colton
     
  18. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    Sounds like a script execution order issue. The enemy is spawned before being assigned the location. I may be wrong though. Have you tried using LateUpdate instead?

    By the way. I hope Jake can add a link to this thread to the asset store page, and to the Curvy 1 thread here: http://forum.unity3d.com/threads/released-curvy-fast-spline-interpolation.170355/page-8

    I think you might not appreciate what a pain it is to Google for this thread.
     
  19. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Hi,

    So I made the plunge and purchased Curvy. I'm very happy with it, but I can't figure out how to change the cross for each control point when I make a shape extrusion.

    Also, I couldn't find an option to interpolate between different shape curves. Ideally I would like to change the shape of my custom extruded mesh along a path, so that each CP could have a different shape curve assigned.

    I could only change the X Y scale but I need to change either the cross, or simply interpolate between different shape curves. I can see how interpolating between different shapes can cause issues with the UV's, but I would rather troubleshoot issues than live without this feature.

    I really hope someone can help me, and I apologize for being so demanding.
     
    Last edited: Dec 4, 2015
  20. petak_core

    petak_core

    Joined:
    Nov 19, 2012
    Posts:
    57
    Hi,

    First of all thank you for great plugin. Curvy is really awesome.

    I'm having some trouble when I make a build for web-player. I have check "Play automatically" in Move section in SplineController but this works only in editor. In web-player doesn't.

    Can anyone tell me what I'm doing wrong ? Thank you for help or any advice.
     
  21. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    Last edited: Dec 6, 2015
  22. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Are you changing InititalPosition in a custom (inherited) controller or from an "external" script?
     
  23. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    A Shape morphing module is on the roadmap, but unfortunately not done yet.
     
    StaffanEk likes this.
  24. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Yes and no. Currently you'll have to inherit a custom controller and change the speed by yourself. You can find the "regular", well known easing methods inside the DTEase (or was it DTTween) class, being part of DevTools.

    I've added this as a feature request. Should be relatively straight forward to add easing to the Animate feature of the builtin controllers. Right now it uses linear tweening, so to say...
     
    Dan2013 likes this.
  25. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    I think full support of easing movement on spline curves will be very useful.
     
  26. bratzka

    bratzka

    Joined:
    Dec 24, 2014
    Posts:
    7
    is it possible to make the path controller seperate from the framerate.
    its moving different when the framerate changes. (like a fixed update type movement)
     
  27. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Yep, every Controller can be updated at Update, LateUpdate or FixedUpdate. Check the UpdateIn property of a controller.
     
  28. bratzka

    bratzka

    Joined:
    Dec 24, 2014
    Posts:
    7
    thanks i found that but was not sure if it is for the controller or the spline itself and apparently i didn't check properly.
    i will try it out.

    another question is it possible to use curvy with chronos?
     
  29. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Assuming that all Chronos does is saving the values of public properties on objects and setting them as you move through the "time" in it, yeah, there should be no issues. Of we can't offer direct support for it or guarantees on how Chronos works, since we're not the developers for it, but being a pretty popular asset, I'm sure Chronos is nicely abstracted and can easily work with Curvy or many other custom components. To be completely sure, I'd ask the Chronos developer while giving him an example of what exactly on the Curvy side you need to rewind or otherwise modify using that system.
     
  30. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Hey Alll,

    I currently have 6 small splines in my scene (all under 200 length (most under 100)) and under 15 CP each). Each spline contains enemies that run along it using a Curvy Controller (total of 25 enemies). When running the game with the splines im hitting around 40fps and when they are disabled around 80. I read and tried the solutions from Page 2 but still having issues. Here are some screen caps of the profiler and my spline components:
    upload_2015-12-23_10-19-23.png
    upload_2015-12-23_10-20-39.png upload_2015-12-23_10-21-1.png upload_2015-12-23_10-21-38.png

    As you can see most of the work is coming from the curvy controller update refresh. When looking at the performance API test scene there is a toggle for interpolate or refresh which seemed to make a huge difference but I didn't see any settings for this on any of the above components.

    Cheers,
    Colton
     

    Attached Files:

  31. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Those stats don't look right, I'll have a look into the SplineController!

    Update: Turns out that the time consumption was caused by Profiler's "Deep Profile"!
     
    Last edited: Jan 3, 2016
  32. Arkolis

    Arkolis

    Joined:
    Feb 6, 2015
    Posts:
    34
    I bought this today super excited to use it but I keep getting the following error Cannot implicitly convert type `UnityEngine.Plane[]' to `Plane[]'
    Any ideas?

    Thanks in advance
    ~Ark
    Edit: Figured it out it was a problem on my end, I found a script I created called plane that was jacking it up. Thanks!
     
    Last edited: Jan 3, 2016
  33. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Nope, unless you give me some more details like a stacktrace of the above error...
     
  34. JiuWei

    JiuWei

    Joined:
    Apr 13, 2015
    Posts:
    7
    hello,InputSplineShape module has a CGModuleOutputSlot OutShape = new CGModuleOutputSlot();Shape Extrusion module has a CGModuleInputSlot InCross = new CGModuleInputSlot();Why CGModuleOutputSlot can be assigned to CGModuleInputSlot,they are not a same class ,could you tell me what happened,thanks!@Jake L.
     
  35. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Slots aren't assigned to each other, instead they link by using CGModuleLink class.
     
  36. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    308
    I'm wondering, is CurvySpline.Length showing the correct value? Or better, is it the real length of the whole spline in game units?
    Because I am using it as a divider to get length values that don't depend from the length of the spline, but at first glance I'm getting some incorrect results. I'm currently investigating it because it could be an imperfection in my code, but I still wanted to ask to be sure. Thanks!
     
    Last edited: Jan 11, 2016
  37. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Yes, it's length in world units. But by nature of splines it's an approximation, not exact math. I.e. it's the length of the polyline build by all approximation/cache points. So the higher your CacheDensity is, the better the result. Also influenced by curvation and spline type.
     
  38. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    308
    Thanks a lot. In the end, I discovered it was indeed an error of mine. :)
    I also have a question about vertices index of generated meshes.
    Let's suppose a very simple, flat road mesh like the one in the image. Black numbers are spline control points, and white numbers are hypothetic vertices index.
    Do first index values (0 and 1) always correspond to the beginning of the spline, or are there cases where they are generated in reverse order? Hope the question makes sense. Thanks again!
     

    Attached Files:

  39. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Order depends on shape spline direction and "Reverse Normal" settings of the Create Volume module. Tip: Play around with the debug modules, they are very helpful for this kind of information.
     
  40. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    I run about 1000 Controllers with about 8% performance loss on a mid range system.

    -------------------------------------
    Another question:
    Is this example valid to wait for all spline to be initialized in the complete scene?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using FluffyUnderware.Curvy;
    4.  
    5. public class WaitForCuvySplinesInit : MonoBehaviour {
    6.     void Start() {
    7.         WaitForCurvySplinesInitialized();
    8.     }
    9.  
    10.     void WaitForCurvySplinesInitialized() {
    11.         foreach (var Spline in FindObjectsOfType(typeof(CurvySpline)) as CurvySpline[]) {
    12.             WaitForSplineInitialized(Spline);
    13.          }
    14.     }
    15.  
    16.     IEnumerator WaitForSplineInitialized(CurvySpline Spline) {
    17.         if (Spline) {
    18.             // Wait until the spline is fully intialized before accessing it:
    19.             while (!Spline.IsInitialized)
    20.                 yield return null;
    21.         }
    22.     }
    23. }
     
    Last edited: Jan 16, 2016
    N3V-Developer likes this.
  41. BirdieL

    BirdieL

    Joined:
    Oct 3, 2015
    Posts:
    7
    Hi, Jake,

    How do I get notified when a certain tf is reached by a spline controller? Thank you.
     
  42. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Looks valid...

    If you're looking for a TF of a given Control Point, just register the OnControlPointReached event and check for it's TF. Otherwise you'll have to check the controller's TF (RelativePosition for SplineController) after each update, either by inheriting a custom controller and overriding UserAfterUpdate() or by checking the property from another script.
     
  43. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    If you use a spline controller by script:

    Think about the TF is not a normalized value on the spline.
    On a spline with 500m length and TF = 0.25 its not 125m.

    Code (csharp):
    1.  
    2. public SplineController MySC;  // attach object with spline controller here
    3. void Update(){
    4.    if (MySC.RelativePosition > 0.5f) {  // returns TF
    5.              // Do anything
    6.    }
    7.  
    8.    if (MySC.AbsolutePosition > 10f) {   // returns absolute Distance on a spline
    9.              // Do anything
    10.    }
    11. }
     
    N3V-Developer likes this.
  44. BirdieL

    BirdieL

    Joined:
    Oct 3, 2015
    Posts:
    7
    Thank you!
     
  45. BirdieL

    BirdieL

    Joined:
    Oct 3, 2015
    Posts:
    7
    Thanks, Jake
     
  46. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    doesn't work this way. return valid length after some frames only.

    Code (csharp):
    1. public class TestScript : MonoBehaviour {
    2.  
    3.    public CurvySpline Spline;
    4.    public SplineController sc;
    5.    
    6.    void Start() {
    7.      WaitForCurvySplinesInitialized();
    8.      WaitForSplineInitialized(Spline);
    9.  
    10.      sc.AbsolutePosition = 5f;
    11.      Debug.Log("sc.Spline.Length " + sc.Spline.Length);  // is 0!
    12.   }
    13.  
    14.  // Update is called once per frame
    15.    void Update () {
    16.         Debug.Log("sc.Spline.Length " + sc.Spline.Length);  // is 0 and after some frames valid
    17.    }
    18.  
    19.    void WaitForCurvySplinesInitialized() {
    20.      foreach (var Spline in FindObjectsOfType(typeof(CurvySpline)) as CurvySpline[]) {
    21.        WaitForSplineInitialized(Spline);
    22.      }
    23.    }
    24.  
    25.    IEnumerator WaitForSplineInitialized(CurvySpline Spline) {
    26.      if (Spline) {
    27.        // Wait until the spline is fully intialized before accessing it:
    28.        while (!Spline.IsInitialized)
    29.          yield return null;
    30.      }
    31.    }
    32. ]
    33.  
    how to code this?
     
    Last edited: Jan 27, 2016
    N3V-Developer likes this.
  47. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    You can do this easily by catching them from all GameObjects. A better solution would be to edit script execution order to ensure that CurvySpline and CurvySplineSegment is processed before your scripts.
     
  48. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    script execution order is set CurvySplineSegment -10. result is 0 as before for some first frames or in start()
     
    N3V-Developer likes this.
  49. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    what is your suggested method different from the following one?
    FindObjectsOfType is method from UnityClass GameObject
    foreach (var Spline in FindObjectsOfType(typeof(CurvySpline)) as CurvySpline[]) {
     
    Last edited: Jan 27, 2016
    N3V-Developer likes this.
  50. N3V-Developer

    N3V-Developer

    Joined:
    Jun 7, 2014
    Posts:
    20
    IEnumerator (yield return null;) didn't work. Should be but does not.
    Try this.
    Code (CSharp):
    1. void WaitForCurvySplinesInitialized() {
    2.      foreach (var Spline in FindObjectsOfType(typeof(CurvySpline)) as CurvySpline[]) {
    3.        while (!Spline.IsInitialized) {
    4.          Spline.Refresh();
    5.        }
    6.      }
    7.    }
     
    Last edited: May 31, 2017
    Quatum1000 likes this.