Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[RELEASED] Curvy 2 - the ultimate spline solution

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

  1. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    1- About the Curvy Generator performance: I never noticed it because I always worked with a small number of modules. Now that I am aware of this, I will fix it in the next update. Until then, I have a quick fix for you. I will send it to you via PM
    2- About connecting modules: for now, and except connecting them through the UI, which can be tedious when having a lot of modules, the only other way is to use the API: cgModuleOutputSlot.LinkTo(cgModuleInputSlot)
    https://api.curvyeditor.com/520/cla...t_slot.html#aad0d70e5cfbc588445e935c4956961ab
    3- About the Range parameter: I will take a look at this tomorrow
     
  2. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    So if I understand your need correctly, you want the Range parameter to be set in absolute distance (between 0 and spline's length) instead of realtive distance (between 0 and 1), right?
    Right now, Shape Extrusion module does not take absolute distances for the Range parameter, but you can easily do that through the API: just create a script that takes two floats, defining your range in absolute distances, and the script divides these number by spline.Length to compute the relative distances, and assigns those values to the related fields in the Shape Extrusion module.

    Here is the code for it
    Code (CSharp):
    1. using FluffyUnderware.Curvy;
    2. using FluffyUnderware.Curvy.Generator.Modules;
    3. using UnityEngine;
    4.  
    5. public class AbsoluteRangeSetter : MonoBehaviour
    6. {
    7.  
    8.     public BuildShapeExtrusion ShapeExtrusionModule;
    9.     public float RangeStart;
    10.     public float RangeLength;
    11.     public CurvySpline Spline;
    12.  
    13.     void Start () {
    14.         UpdateRange();
    15.     }
    16.  
    17.     void Update ()
    18.     {
    19.         UpdateRange();
    20.     }
    21.  
    22.     void UpdateRange()
    23.     {
    24.         ShapeExtrusionModule.From = RangeStart / Spline.Length;
    25.         ShapeExtrusionModule.Length = RangeLength / Spline.Length;
    26.     }
    27. }
    28.  
    This script does the modification in play mode. You will need it to work in edit mode. I let you do that. Here is some useful documentation https://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html
     
  3. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
  4. wantondalliance

    wantondalliance

    Joined:
    Aug 22, 2018
    Posts:
    29
    I've got an issue with using Curvy - wondering if anybody could help. Apologies if I've posted this in the wrong place.

    https://vimeo.com/user9514265/review/334878880/47190ba5ac

    As shown in the video, I've set a Motor Controller to 'absolute', but the motor still seems to slow down at the spline handles. It's particularly noticeable at the second to last handle. I'm trying to get the motor's speed to be totally constant.
     
  5. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    Hi,
    The link is not working. Are you sure you set Absolute to the Move Mode and not Position Mode parameter?
     
  6. wantondalliance

    wantondalliance

    Joined:
    Aug 22, 2018
    Posts:
    29
    Yes, both are on Absolute

    Here's the video:


    + FWIW I am working at 0.01 scale, perhaps this is causing issues? It's for physics reasons.
     
    Last edited: May 8, 2019
  7. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    Hmm, I don't see an explanation for that. Can you please send me a reproduction scene so I can debug this?
     
  8. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    Also, this reminds me that I haven't announce it yet:
    Curvy is on sale: -50% until May the 15th
     
  9. wantondalliance

    wantondalliance

    Joined:
    Aug 22, 2018
    Posts:
    29
    I've sent a packaged scene to you :)
     
  10. neferatum

    neferatum

    Joined:
    Apr 19, 2019
    Posts:
    2
    Hello, I have recently purchased the Curvy spline tools and the plugin is awesome..! I am trying to dynamically add the SplineController to the game object using AddController but I keep getting the following error:


    NullReferenceException: Object reference not set to an instance of an object
    FluffyUnderware.Curvy.Controllers.CurvyController.Initialize () (at Assets/Plugins/Curvy/Controllers/CurvyController.cs:788)
    FluffyUnderware.Curvy.Controllers.CurvyController.Start () (at Assets/Plugins/Curvy/Controllers/CurvyController.cs:537)


    Is there any function I need to run directly after AddComponent? or have I forgotten to set a variable?

    Thanks in advance.
     
  11. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    Hi,
    Can you send me a reproduction scene so I can debug this?
    In general, you have to assign the Spline variable, like what you do when you create the controller through Unity's UI, but this doesn't seem to be the issue here.
     
  12. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    I attached a zip containing a scene and script that create at runtime a SplineController. The code is simple
    Code (CSharp):
    1. using FluffyUnderware.Curvy;
    2. using FluffyUnderware.Curvy.Controllers;
    3. using UnityEngine;
    4.  
    5. public class RuntimeControllerTester : MonoBehaviour
    6. {
    7.     void Start () {
    8.         SplineController splineController = gameObject.AddComponent<SplineController>();
    9.         splineController.Spline = FindObjectOfType<CurvySpline>();
    10.         splineController.Speed = 10;
    11.         splineController.Play();
    12.     }
    13. }
    Does this code work for you or does it generate the error too?
     

    Attached Files:

  13. marvalshot

    marvalshot

    Joined:
    Dec 29, 2013
    Posts:
    157
    I feel like a dope but how come nothing shows up when i create control points. It gets added to the scene view but nothing renders????

    Never mind.
    Gizmos must be on in scene view. Duh
     
  14. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    Hi,
    The spline does not render in Game view by default because not all users want to do display their splines.
    See the control points, and the spline itself, as just data. Each user will want to do something different with it. Some people will use a spline to make an object move along it, some other people will use it to extrude a mesh along it, both of which don't need to render the spline.
    If you want to render a spline, you can use a Curvy GL Renderer, like used in example scene 00_SplineController; or a Curvy Line Renderer like used in scene 04_PaintSpline.
     
  15. neferatum

    neferatum

    Joined:
    Apr 19, 2019
    Posts:
    2
    Hi,

    No, unfortunately this message is repeated, the spline is working though but the amount of messages is too large..

    Thanks a lot!
     
  16. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    Hmm, that is weird. Can you please:
    1- tell what exact version you use
    2- tell me if you modified any source code of Curvy
    3- send me a reproduction case
     
  17. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    Arkolis likes this.
  18. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    491
    Hi, I'm profiling to optimize my game and I find that Curvy is using about 0.2ms running Train sample. It doesn't seem a lot but it represents about 10% of the whole CPU cycles used up by Curvy if you exclude Camera.Render.
    I would like to know if this is normal since all it's doing is following a spline path.
    upload_2019-8-12_22-23-16.png

    Also, I find that ScanConnections() is getting called about at every 1/10 of seconds while "Playing" and in turn, it's calling GameObject.FindObjectsOfType<CurvyConnection>() which is quite expensive operation. It's Editor only event but it doesn't seem necessary to call whenever "hierarchyChanged" event is fired, instead check only at the Start or something.

    Thanks.
     
  19. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    Hi,

    1- Curvy controller can probably be further optimized. I will give it a try later this week. Just so I can get an idea about your target, how much ms do you expect Curvy to take?
    In my attempt, I will of course try to optimize the controllers while keeping the same features, so that it can be used by everyone. But, if you don't use connections nor events with your controllers, I can send you a custom version of the controller's code that does not support these features, and that will use way less CPU time. Also, what kind of Clamping do you need with your controllers?

    2- In my tests, ScanConnections is not called often, so I assumed that it calling FindObjectsOfType should not be an issue.
    Based on hierarchyChanged's documentation, "Actions that trigger this event include creating, renaming, reparenting, or destroying objects in the current hierarchy, as well as loading, unloading, renaming, or reordering loaded Scenes. Note that the event is not raised immediately in response to these actions, but rather during the next update of the editor application."
    So it should not be called that often when playing. Can you tell me what is your use case that made it be called every tenth of a second?
    Checking only at Start (or similar) will not do the intended effect because objects created after the Start method will get ignored. I need something that will be checked at each creation and destruction of an object. Maybe there is a better way than hierarchyChanged, but before starting to look for something else, I need first to read your answer to the above question.

    Thanks and have a nice day
     
  20. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    491
    Hi, thanks for the quick reply.
    I don't have specific target optimizations but asking if that's normal. Right now, Train sample is pretty simple path-following example yet it uses quite a significant portion of the whole CPU cycle.
    I'm not sure I should use Curvy for the runtime path-following. Curvy is very nice for creating path objects but may not as efficient as other simple path-following solutions.
    How about superfast path-following option if all I want is simple spline path-following during runtime without complicated features? I think it will be useful in many situations and make Curvy more useful. Otherwise, I might have to have another spline solutions and I hate to have two similar solutions in a single project.

    I have objects, for example, such as bullet shell, particle effect is triggering the hierarchy changes. If Start is not an answer, perhaps CurveyConnection to register itself to the list might be a better approach, I think. ^^
    Cheers!
     
  21. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    491
    Here is one more optimization issue. Having prefab is much more desirable for efficient memory and fast rendering. For example, GPUInstancer requires prefab in order to take advantage of instancing. However, Curvy always converts to non-prefab and I have to manually change them to prefab after Curvy generates GameObjects.

    The following image is from the same Train example. I created a prefab and gave the prefab as an input, but it turns them into GameObjects. If the input is a prefab, the end result should be prefab. Having GPU Instancing (it will render 1000s of GameObject in a single drawcall) will make the train example to run about twice as fast in my test.

    Thanks.

    upload_2019-8-13_2-55-31.png
     

    Attached Files:

  22. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121
    Thanks a lot for finding those optimization suggestions. I will work on this this week, and provide you with an optimized version. I will then add them to the next update
     
    chrisk likes this.
  23. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    121