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. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    724
    Thanks a lot perfect! :D
     
    N3V-Developer likes this.
  2. N3V-Developer

    N3V-Developer

    Joined:
    Jun 7, 2014
    Posts:
    19
    Another code that is tested.

    Code (CSharp):
    1. IEnumerator Start() {
    2.         foreach (var Spline in FindObjectsOfType(typeof(CurvySpline)) as CurvySpline[]) {
    3.             while (!Spline.IsInitialized) {
    4.                 yield return null;
    5.             }
    6.         }
    7.     }
     
  3. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    676
    I'm getting an index out of bounds error when calling LocalFToDistance in CurvySplineSegment. ApproximationDistances sometimes only has length of 1, despite the curve having more points than that. So I had to put try catch around LocalFToDistance invocation.
     
  4. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Is there a chance you can reproduce that? If yes, please raise a bug report (using the curvy toolbar), otherwise I suggest to discuss settings and code in-depth in our support forum to get that sorted.

    Thanks a lot
     
  5. lapoune

    lapoune

    Joined:
    Jul 21, 2012
    Posts:
    1
    Hello Jake,

    Is there a way to easily control the speed or velocity of the object following the spline, similar to the ease of use of the orientation functions? Is this something that could be added?

    Thank you!
     
  6. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    779
    You can easily make a custom component with an AnimationCurve field that will get the absolute controller position (0-1) and set the controller speed based on it by evaluating the AnimationCurve. LeanTween-like tweening functions can be used the same way, they are just faster, since some easing functions can be described without a curve.

    Maybe we should add an example script doing just that. :)
     
  7. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Doing a custom controller is one option, but perhaps the "Animate" feature of the SplineController is sufficient for your needs. After enabled you can move a defined distance (y) over a defined time (x) using an AnimationCurve ranging from 0..1 on both axis.
     
  8. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    504
    does it also support runtime spline creation? like for a racetrack editor for example?
     
  9. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26

    I have the same issue. How do I initialize the SplineController if it will not autostart in Web Player.
     
    Last edited: Feb 11, 2016
  10. ColtonK_VitruviusVR

    ColtonK_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    146
    Hey All,

    I need to create a fairly lengthy spline (train track) for one of my levels with many control points. In terms of performance, would it be better to create several short splines and connect them or 1 long one? Is there any specific parameters on the spline or spline controller that could make or break my performance with long splines?

    Thanks,
    Colton
     
  11. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    779
    @Der_Kevin
    Yes it does! All relevant classes and methods work well at runtime and are performant enough not just for stuff like in-application level editors, but even for gameplay-time generation. For example, you can create a level for an infinite runner game through CG generator driven extrusions requested by your runtime script.

    @Petha
    Thanks for the info, we'll look into it!

    @ColtonK_VitruviusVR
    There should be no significant difference in performance cost of creating or updating the spline and other stuff like extrusions. If you are using a spline to create an extruded mesh with a Curvy Generator, though, there are a few settings you might want to try - for example, shape generation module can split your extrusion into multiple volumes, which will allow you to take advantage of frustum culling, as Unity will stop rendering meshes outside of camera view. Other properties worth a look are resolution related (in the shape module) - tweak them until you're satisfied with polycount and make sure to check the optimized mode to get only the vertices necessary for the silhouette, not uniform subdivision.
     
  12. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    @bac9-flcl

    How do I initialize the SplineController? I only found the bool that autostarts the controller.
     
  13. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    It >should< initialize automatically and properly start playing, but there were some issues with the current implementation (solved in 2.0.5).

    In general, you yield return until the controller has IsInitialized==true (see here).
     
  14. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    Yield what exactly? What exactly is the code to initialize a controller. The documentation is a bit slim to be honest.

    I don't want to add a spline, I want to initialize a controller. Do I disable it by default. And then use coroutine to enable it again after it has initialized. How can it initialize, if it is turned off? How do I initialize the SplineController? I don't see how waiting for the controller to be initialized is helping me since it is the initialization I'm trying to achieve.

    Also the documentation is devoid of any mention of how to use the generator in scripts. I'm trying to get the amount of spots from a "BuildVolumeSpots" CGModule.

    Here is my unfruitful attempt:

    Code (csharp):
    1.  
    2.   public CGModule BVspots;
    3.   public int spotammount;
    4.  
    5.   void Update()
    6.   {
    7.   BVspots.GetComponent<CGSpots>();
    8.   CGSpots hgtr = hello.GetComponent<CGSpots>();
    9.   CGSpot[] asd = hgtr.Points;
    10.   spotammount = asd.Length;
    11.   }
    12.  
    I'm just blindly trying out different combinations really. I have no idea what I'm doing since the generator component is very undocumented.
     
  15. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    504
    Thanks for the info, sounds great :) is there example somewhere for the runtime creation? What i want to do is, somehow drawing a spline at runtime with my mouse, and be able to modify it also later. Or is there a example in the pack?
     
    Last edited: Feb 15, 2016
  16. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    779
    @Der_Kevin

    There is an example with spline drawing - 04_PaintSpline.unity in the Curvy Examples/Scenes. And I think Jake had an example in the works with an infinite runner level generation (CG extrusions).
     
  17. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    Anyway. I can get the amount of spots in other ways but what I really want to do is to change the amount of spots, based on the amount of them in the scene.

    I got this far, but without extensive documentation it's a bit hard to know how everything hooks up.

    Code (csharp):
    1.  
    2.  
    3. public CGModule mySpotsModule;
    4. public FloatRegion mySpaceAfterValue;
    5.  
    6. void Update()
    7. {
    8.      CGBoundsGroup m_MyBoundsGroup = mySpotsModule.GetComponent<CGBoundsGroup>();
    9.      mySpaceAfterValue = m_MyBoundsGroup.SpaceAfter;
    10. }
    11.  
    12.  
    This is the error I get:

    Code (csharp):
    1.  
    2. GetComponent requires that the requested component 'CGBoundsGroup' derives from MonoBehaviour or Component or is an interface.
    3.  
    I'm not sure how I'm supposed to get the CGBoundsGroup in my BuildVolumeSpots module. Do I have to call it by its name? How do I do that?
     
  18. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    504
    Sounds great. Can i kindly ask for a videocap of that? A gif is enough. Just to see if it is that what i need :) thanks!
     
  19. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    I wonder if it would be possible to get answers to my questions? Thank you very much.
     
  20. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    198
    Pre-sale question.

    Is it possible to instantiate a prefab along a spline. Say, I have one unit of a train track (custom made model, not a spline profile). Is it possible to instantiate it so they are deformed and connected along the spline?
     
  21. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    Are you asking about deforming the track mesh? That isn't yet possible with this version, but you can instantiate along a curve. It works great.

    Generating geometry in the form of just about any mesh is easy with Curvy however. You can even assign UVs to your generated mesh.
     
    Rod-Galvao likes this.
  22. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Of course, sorry.

    First, SplineController. If you need to work with it from other scripts, you usually would use Start() to wait ("yield return") until IsInitialized becomes true. See the link I've posted (example code uses a spline, but it's completely the same mechanism). Alternatively, you can check in Update() or anywhere else if IsInitialized is true before accessing the controller. It's depending on the way you like to design your scripts.

    CG by API: I agree documentation is a bit sparse in that area, we'll need to improve that. Saying that, we noticed that CG-API needed some love to make interaction easier and we did this for 2.0.5. What you need is to first get the module (GetComponent<> for now works fine, 2.0.5 adds a "Generator.FindModule<T>()" to ease that. Once you have a reference to the module, you can access properties and data:

    Code (csharp):
    1.  
    2. BuildVolumeSpots mod=... // get reference to your module in question
    3. mod.Groups[0].SpaceBefore.From=12.34f; // set SpaceBefore
    4.  
    Be sure to use the corresponding module class for your reference, so you can browse it's individual properties.
    To access the calculated spots, you'll need to fetch the cached output data:

    Code (csharp):
    1.  
    2. if (mod.OutSpots.HasData)
    3.    Debug.Log(mod.OutSpots.Data[0].Count +" spots generated");
    4. // alternative version:
    5. var spots=mod.OutSpots.GetData<CGSpots>();
    6. if (spots!=null)
    7.    Debug.Log(spots.Count);
    8.  
     
  23. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    @Jake L.

    Thank you for taking the time to answer my questions.

    I don't think you really understood my question however. In my question about the initialization of a controller you have simply reiterated your previous response. I think it should be quite obvious that it is the content of your previous answer that left me wanting. Not the frequency of the answer to my one question. The frequency was fine. One informative answer is enough.

    Maybe my question simply wasn't clear enough?

    What is the piece of text I need to type in my C# script in order to make the controller move?

    The following is a direct quote from your documentation.

    That's fine. But what TEXT do I have to write in my C# script if I cannot use Play automatically. I didn't write Curvy, so I don't know how you set everything up. I could dig through all the inherited classes you wrote to find the text you arbitrarily choose to use in order to initialize a controller. But why exactly should I go through all that trouble when it could just be documented in the first place?

    Why is that such a big secret? Are you trying not to offend me by not spelling it out plainly or something? I'm not offended if you treat me like an idiot and just spell it out. I don't mind. I'm on a deadline and neither care, or have time for emotions and feelings. Just assume I am an idiot. Believe me, you will save yourself a lot of time by avoiding this back and forth dialog. It's literally one line of code you have to write. What could possibly be faster or simpler than that?

    About my second question.

    I have already gotten the module by simply making it public and dragging it in the right slot in the inspector. (That's simple and good enough for my current non-gamedeveloping needs) I have however wrote as you instructed. I have even used your coroutine initialization for all code related to curvy to no measurable effect.

    I am using the FluffyUnderware.Curvy.Generator and FluffyUnderware.Curvy.Generator.Modules namespaces. You didn't mention what namespaces I need to include.

    When I attempt to use your example I wrote:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using System;
    5. using FluffyUnderware.Curvy.Generator.Modules;
    6. using FluffyUnderware.Curvy.Generator;
    7.  
    8. public class MyRetardedScript : MonoBehaviour
    9. {
    10.  
    11. public BuildVolumeSpots mod;
    12.  
    13. Update()
    14. {
    15. mod.Groups[0].SpaceBefore.From = 12.34f; // set SpaceBefore
    16. }
    17. }
    18.  
    I am greeted with the following error message:

    Code (csharp):
    1.  
    2. error CS1612: Cannot modify a value type return value of `FluffyUnderware.Curvy.Generator.CGBoundsGroup.SpaceBefore'. Consider storing the value in a temporary variable
    3.  

    Did you use pseudocode in your answer? Again, I didn't write Curvy, so I don't know intuitively how you chose to set everything up. so in order to alleviate confusion It would be simpler if you just wrote the answer script with included namespaces and custom declarations.

    I did manage to change the SpaceBefore value by using your custom FloatRegion struct. The problem is that it had no effect on the actual amount of spots in-game. This isn't surprising since the value I am changing probably isn't the actual private variable used by Curvy internally. (I tried to wait for initialization too, no difference)

    I really need the specific piece of text to write in my scrips. Let's just say I have one chromosome to much to understand pseudocode.

    Thank you very much for your time. I do appreciate the time you took to help me out even though my tone might indicate otherwise.


    EDIT: Ok obviously I can just initialize the CurvyGenerator by script. But the spline controllers don't have an initialize function???!! Again, I can't simply intuit this?
     
    Last edited: Feb 19, 2016
  24. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    You're right, it wasn't clear enough. You always talked about initialization, not start playing. That's something completely different. To start playing, just use "Play()"

    No, that wasn't pseudocode, just written down from my head without opening Unity, creating a script, writing it, copy&pasting it. This obviously was a code snippet, not a complete class file example, so namespaces (like a class and method definition) wasn't part of that snippet by intention. Though the bug wasn't: SpaceBefore is a struct indeed, but the solution is simple and clear and part of the error message you posted.

    Finally, here's your special meal:
    Code (csharp):
    1.  
    2. // Copy & Paste Solution - place inside the /Asset folder and name the file 'MyRetardedScript.cs' :D
    3. using UnityEngine;
    4. using FluffyUnderware.Curvy.Generator.Modules;
    5. public class MyRetardedScript : MonoBehaviour
    6. {
    7.     public BuildVolumeSpots mod;
    8.  
    9.     void Update()
    10.     {
    11.         var sb = mod.Groups[0].SpaceBefore;
    12.         sb.From = 42.42f; // set SpaceBefore
    13.         mod.Groups[0].SpaceBefore = sb;
    14.         mod.Dirty = true;
    15.     }
    16. }
    17.  
    Exact, did I state something different? Let me copy&paste the code I linked above and replace Spline with SplineController:

    Code (csharp):
    1.  
    2. //Add some favorite namespaces, class structure etc...
    3. SplineController SC;
    4.  
    5. IEnumerator Start()
    6. {
    7.   if (SC)
    8.    while(!SC.IsInitialized)
    9.       yield return null;
    10. }
    11.  
    12. void Update()
    13. {
    14.    if (SC.IsPlaying)
    15.        Debug.Log("W00T !!!!111!!!!");
    16. }
    17.  
    Cheers,
    Jake
     
  25. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    @Jake L.


    Thank you very much. That's digestible even for the likes of me.
     
  26. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    545
    HI,
    Is there a way to make an object follow the rotation of the Control Points as apposed to the path? The problem I'm having is that the orientation seams to rotate around the spline but I want the object to follow the spline and average the rotation between two control points. See Image:
    upload_2016-2-25_1-4-27.png
     
  27. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Sure, either set spline's orientation to static or use dynamic and check one or more CP's OrientationAnchor. You then can rotate the CP's to influence the calculated orientation.
     
  28. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    545
    Tried that,
    My spline is set to static. I have the cps rotated. My spline mover is set to Orientation up. Perhaps I'm missing something in the directions?
    Picture of how it looks:
    ShipNotAligned.PNG

    How I want it to be aligned:
    ShipAligned.PNG

    I would just offset the ship but I want to use the curve to animate it's rotation separate from its movement. Right now try as I may I can't get the mover to follow the CPs. I can get them to "roll around" the line via the orientation of the control points but that's it. I need to be able to control the pitch and yaw via control points, right now I can only control "roll" if that makes sense?

    Thoughts?
     
  29. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    779
    I'm not sure I understand what you're trying to do. Correct me if I'm wrong:
    • You like the tangent-driven rotation of the controller, since you want your platform to rotate horizontally along the path (it's a platform, right?)
    • You don't like the orientation-driven rotation of the controller (pitch/roll), since you want the platform to be horizontal
    • You have set the spline orientation mode to static, removing orientation data from it
    If that's the case, then you already have a proper setup, platform shouldn't be rotated non-horizontally and should stay that way along the whole path.

    If that's not the case, can you provide a screenshot with multiple copies of that object placed along the path and oriented the way you want? Preferably with a much more intensive curve between the points, since there is almost no difference in tangent between the two depicted points, making it hard to understand the intent.
     
  30. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    @Jake L.

    about SplineController.Play().
    I have tried everything. First of all. Checking whether a SplineController is initialized only works on some of my SplineControllers. My co-routine simple yields for all eternity.

    I knew i tried .Play(); before but simply assumed .Play() wasn't related to Curvy, since it didn't actually do anything.

    The only way I have gotten SplineController.Play() to constantly work if I put it into the Update function. Which I assume is not the way to go.

    Putting SplineController.Play() in Update doesn't work with the Web Player though. The Spline controller simply refuses to work in the web player.

    Building the webplayer simply kills SplineControllers for me.

    Here is my script, the co-routine only works some of my SplineControllers. And when in the web player. No spline controllers work.

    Code (csharp):
    1.  
    2.  
    3. public SplineController rollerCoaster;
    4.  
    5. start()
    6. {
    7. StartCoroutine(Start());
    8. }
    9.  
    10.  
    11. IEnumerator Start()
    12. {
    13. while(!rollerCoaster.IsInitialized)
    14. yield return null;
    15. rollerCoaster.Play();
    16. }
    17.  

    @bac9-flcl

    It has been a while now. Any news? Could you simply send me a new CurvyController script that works.
     
  31. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,097
    Hi Jake, Sent you an email, but just in case you didn't get it, Curvy doesn't work on Windows Store target.

    Here are the errors:

    Assets\Packages\DevTools\Extensions\Extensions.cs(19,36): error CS0234: The type or namespace name 'Formatters' does not exist in the namespace 'System.Runtime.Serialization' (are you missing an assembly reference?)
    Assets\Packages\DevTools\Classes\ThreadPoolWorker.cs(20,35): error CS0246: The type or namespace name 'WaitCallback' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Packages\DevTools\Classes\ThreadPoolWorker.cs(30,35): error CS0246: The type or namespace name 'WaitCallback' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Packages\DevTools\Classes\ThreadPoolWorker.cs(105,20): error CS0246: The type or namespace name 'WaitCallback' could not be found (are you missing a using directive or an assembly reference?)

    I think some of the .net features you are using are not available on Windows Store or Windows Phone, What do I do I'm trying to release my game today on Windows Store and I've used Curvy heavily in my game!

    Any ideas?
     
  32. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    545
    To try and clarify I want the object to use the path for positioning but the control points for rotation (so the rotation is the mix of the previous and next control points. E.g. if I'm .25% of the way from the previous to the next point it would be something like (Psudo code): Rotation == PreviousPoint.Rotation *.25 + NextPoint.Rotation *.75 /2 = MyControllerRotation.

    Here is what I'm trying to achieve:
    ShipRotation.jpg

    here is my current setup (I've tried every variation I can think of:
    CurvySetup1.PNG
    CurvySetup2.PNG

    Thanks for any help.
     
  33. sindrijo

    sindrijo

    Joined:
    Mar 11, 2014
    Posts:
    10
    I've tried to use the SplineController in the webplayer too and it is not supported (right now at least) because it uses reflection (a C# feature) to inspect some private variables in a UnityEvent to decide between two implementations that move the object (among other things) as an optimization. To get it to work you need to edit the source code of SplineController so that it doesn't use the HasListeners() function when building for the Webplayer by adding use of the #IF compiler directive.
     
  34. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    @sindrijo
    Thank you for helping me out. My problem is that I rely on the event system. I am using the OnControlPointReached event.

    I modified the SplineController as you suggested, and it works in the Editor but if I build a webplayer then my controllers still won't budge. Here are the parts where I found the HasListeners() function. I'm not using switching at all, so I don't care if that works.

    Code (csharp):
    1.  
    2.   if (IsSwitching)
    3.   {
    4.   mSwitchEventArgs.Delta = Mathf.Clamp01((Time.time - mSwitchStartTime) / mSwitchDuration);
    5. #if !UNITY_WEBPLAYER
    6.  
    7.   if (OnSwitch.HasListeners())
    8.   onSwitchEvent(mSwitchEventArgs);
    9.   else
    10. #endif
    11.   mSwitchEventArgs.Data = mSwitchEventArgs.Delta;
    12.   }
    13.  
    Code (csharp):
    1.  
    2.   if (m_OnControlPointReached != null)
    3.   {
    4. #if !UNITY_WEBPLAYER
    5.   if (m_OnControlPointReached.HasListeners())
    6. #endif
    7.   Spline.OnMoveControlPointReached.AddListenerOnce(onControlPointReachedEvent);
    8.   }
    9.  
    10.   if (m_OnEndReached != null)
    11.   {
    12. #if !UNITY_WEBPLAYER
    13.   if  (m_OnEndReached.HasListeners())
    14. #endif
    15.   Spline.OnMoveEndReached.AddListenerOnce(onEndReachedEvent);
    16.   }
    17.  
     
  35. sindrijo

    sindrijo

    Joined:
    Mar 11, 2014
    Posts:
    10
    Ah.. you need to also edit CurvySpline.cs otherwise it will cast a runtime exception (which will incidentally not crash the player, but it will be logged), there are a few places it's used here is an example of a change I made to make it work:


    Code (CSharp):
    1.        
    2. public override Vector3 Move(ref float tf, ref int direction, float fDistance, CurvyClamping clamping)
    3.         {
    4.             // Simple case
    5. #if !UNITY_WEBPLAYER
    6.             if (!OnMoveControlPointReached.HasListeners() && !OnMoveEndReached.HasListeners())
    7.  
    8.                 return base.Move(ref tf, ref direction, fDistance, clamping);
    9.             else
    10. #endif
    11.                 return eventAwareMove(ref tf, ref direction, fDistance, clamping, false);
    12.         }
     
  36. Petha

    Petha

    Joined:
    Dec 4, 2015
    Posts:
    26
    @sindrijo

    Thank you very much. It works flawlessly. How did you figure out that using reflection was the issue, or that was unsupported in the Web Player for that matter?
     
  37. sindrijo

    sindrijo

    Joined:
    Mar 11, 2014
    Posts:
    10
    I just looked at the logs produced by the webplayer when it was not working, it logged an exception that had something to do with security if i recall correctly, the stack-trace pointed to the HasListeners method and then I remembered that the webplayer has some restrictions so I looked at http://docs.unity3d.com/Manual/SecuritySandbox.html and there it was:

    Curvy is using reflection to check an internal variable in a UnityEvent. Though it's not required for it to work, just an optimization in Curvy that allows it to use a faster implementation for moving along the spline, I have no idea how much performance Curvy gains by doing this I haven't read through that part of the code.

    That documentation page also mentions that the reflection part of the security sandbox is not emulated in the Editor, so when testing you wouldn't get the error. (Like you just described.)
     
    Last edited: Mar 3, 2016
  38. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,097
    Anyone know where support has gone? I've not had a reply to email or this forum and I've got a game I can't release because of Curvy.
     
  39. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    No, support isn't gone, but I've got strucked by the flue early this week. Currently I'm hardly able to stand a few minutes working on my PC, sorry. On top, Bac is heavily bound by one of his projects. But I'll answer every mail and request that has queued up as soon as I'm healthly again.

    Regarding the webplayer issue:

    2.0.5 is submitted and the next release will focus on platform support (IL2PP, Win Universal etc.), we'll address those issues there. That internal variable we catch by reflection is needed to check whether an event is bound or not. Unity offers no other way to tell if a user has dynamically subscribed to an event or not. Well, they could have made their internal counter a public property (please support this here!), but unless that, no chance. So for some platforms we have to sacrifice flexibility or offer workarounds, and we will.
     
  40. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,097
    Thanks, get well soon. I really need a Windows Store fix asap.
     
  41. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    Hey Jake,

    Great work on v2.0.5 - it's looking great. Just found a small bug in CurvyController.cs. Looks like mIsPrepared isn't getting set in the Editor in a timely fashion, so IsInitialized() isn't returning true, so VolumeControllers aren't being refreshed properly in the Editor.

    When you play the game everything is positioned fine, but when you stop playing then the VolumeControllers don't refresh properly and are mis-positioned. This is my temporary fix:

    Code (CSharp):
    1. //public virtual bool IsInitialized { get { return IsConfigured && mIsPrepared && (MoveMode==MoveModeEnum.Relative || Length>0); } }
    2.         public virtual bool IsInitialized { get { return IsConfigured && (MoveMode==MoveModeEnum.Relative || Length>0); } }
    Ben
     
  42. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Thanks, I'll look into this.
     
  43. szagii

    szagii

    Joined:
    Jul 13, 2014
    Posts:
    7
    Hey,

    I love Curvy and I started making simple on rail platformer prototype :)

    But I have some questions, it is possible to move along spline using transform.Translate? Or I should use some spline controller on wagon and my player will follow this? but i will need smoothly change speed depends on collisions so for this using easing functions is good approach?

    Thanks, for any help :)
     
  44. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    Thanks Jake. Another small problem in one of the example files: Assets/Packages/Curvy Examples/Scripts/SceneSwitcher.cs (59). "EditorBuildSettings" is used without #if UNITY_EDITOR flags around it, so this breaks the player build process.

    No biggy, but would be nice to fix in the next version. Thanks!

    Ben
     
  45. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    I'd use a SplineController (or a custom controller inherited from it), either directly or as a target that moves a bit ahead your player. Managing Speed would then be done in your custom controller, see here (and examine the examples) on how to override the relevant methods.

    For any detailed discussion on how to implement things or detailed help on various programming issues I'd like to recommend our support forum (keeping multiple topics in multiple threads making things easier).
     
  46. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    724
    Here "wait for spline initialized" doesn't work for me on 2.0.5.
    Code (CSharp):
    1.     IEnumerator Start() {
    2.             foreach (var Spline in FindObjectsOfType(typeof(CurvySpline)) as CurvySpline[]) {
    3.                 while (!Spline.IsInitialized) {
    4.                     yield return null;
    5.                 }
    6.             }
    7.           PrepareGameObjects();
    8.         }
    9.  
    PrepareGameObjects() is used in the latest stage to calculate all objects with the move API but it's never called. Is it the wrong position to call in start() ?

    Or would it better to call for the complete spline initialization in awake?

    Code (CSharp):
    1. void Awake(){
    2.       // do something
    3.      WaitForSplines();
    4. }
    5.  
    6. IEnumerable WaitForSplines() {
    7.     foreach (var Spline in FindObjectsOfType(typeof(CurvySpline)) as CurvySpline[]) {
    8.       while (!Spline.IsInitialized) {
    9.           yield return null;
    10.       }
    11.    }
    12. }
    13.  
    14. void Start() {
    15.   PrepareGameObjects();
    16. }
    17.  
    18. Vector3  PrepareGameObjects();
    19.     if (StartSpline.IsInitialized)
    20.     {
    21.        if (StartSpline.Length > 0)
    22.        {
    23.          StartPosition = Mathf.Max(Mathf.Min(StartSpline.Length, StartPosition), 0);
    24.          LeadTF = StartSpline.DistanceToTF(StartPosition);
    25.          var pos = StartSpline.InterpolateFast(LeadTF) + StartSpline.transform.position;
    26.          return pos;
    27.        }
    28.      } else {
    29.        Debug.Log("StartSpline is not initialized" + StartSpline.name);
    30.        Debug.Break();
    31.      }
    32. }
    33.  
    3rd example with coroutine

    StartCoroutine(WaitForSplines());
    IEnumerator WaitForSplines() no succsess.

    Edit:
    Vector3 PrepareGameObjects() {
    StartSpline.Refresh() // produce a null reference error on Stop
    if (StartSpline.IsInitialized)

    NullReferenceException: Object reference not set to an instance of an object
    FluffyUnderware.Curvy.CurvySpline.Refresh () (at Assets/Packages/Curvy/Base/CurvySpline.cs:1604)


    What's the better approach? But StartSpline is never initialized for any reason... :-/
    Jake would you so kind and post a valid example to wait for all spline initialized please!
     
    Last edited: Mar 23, 2016
  47. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Your first example is the right one and should work, you'll need to wait for initialization in Start() - doing this in Awake() won't work. The only reason why this might fail is that something goes wrong in the foreach() part. Did you tried to fetch the array first, then iterating over it?

    Code (csharp):
    1.  
    2. IEnumerator Start() {
    3.            var splines=FindObjectsOfType(typeof(CurvySpline)) as CurvySpline[];
    4.            foreach (var Spline in splines) {
    5.                while (!Spline.IsInitialized) {
    6.                     yield return null;
    7.                }
    8.            }
    9.           PrepareGameObjects();
    10.        }
    11.  
    If that's not working please contact me by mail/PM, I'd love to have a look over the particular scene then - if possible.

    Thanks,
    Jake
     
  48. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    724
    Thanks! Update is reached before start has finished.

    Code (CSharp):
    1.  
    2. private _SplinesNotInitialized = true;
    3. IEnumerator Start()
    4. {
    5.   var splines=FindObjectsOfType(typeof(CurvySpline)) as CurvySpline[];
    6.   foreach (var Spline in splines) {
    7.      while (!Spline.IsInitialized) {
    8.        yield return null;
    9.      }
    10.   }
    11.   PrepareGameObjects();
    12.   _SplinesNotInitialized= false;
    13. }
    14.  
    15. void Update()
    16. {
    17.   if (_SplinesNotInitialized) return;
    18. }
    19.  
    20. void PrepareGameObjects() {
    21. }
    22.  
    does the trick!
     
  49. Industrion

    Industrion

    Joined:
    Nov 21, 2013
    Posts:
    41
    Hi,

    Is there a way to make an object follow a spline in reverse? Specifically, UnityEngine.UI.Text, using the UITextSplineController class.

    I tried a few things - making Speed and/or Timescale negative, and changing the animation curve, but none of these achieved what I was looking for. I also tried setting mySplineController.Direction to -1 and that kind of thing, but had no success.

    Alternatively, is there a quick way to reverse the Spline without manipulating its gameObject's transform (I don't want to do that since there are UI elements as children to that gameObject transform)?

    I'd be looking to use the Loop clamp, also.

    Thanks
     
  50. ColtonK_VitruviusVR

    ColtonK_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    146
    Hey All,

    In a scene I have approx. 12 inter-connected splines (20-30 connections). I haven't touched this scene for a few weeks and have recently updated to Unity 5.3.3p1. Upon working on the scene today I noticed that none of the splines are connected. When I attempt to reconnect the splines they wont stay connected (i.e. every time I connect them, and either play or exit the editor they don't stay connected). Any thoughts?

    Cheers,
    Colton

    EDIT: I should have also mentioned that I have looked at splines in other scenes and they still seem to be connected.

    I stand corrected. Upon editing other scenes with splines in them the connections have disappeared and they behave exactly as above.

    The Curvy update 2.0.5 fixed the issues - Thanks Jake L.
     
    Last edited: Mar 29, 2016