Search Unity

Corgi Splines - Extremely fast and easy spline editor and jobified spline access.

Discussion in 'Assets and Asset Store' started by funkyCoty, Jul 26, 2020.

  1. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    really glad you're enjoying it. I saw unity's new internal spline system and got irrationally angry, which inspired me to keep working on this one. I've been using it both at work and on personal projects pretty heavily, so anytime I find something even slightly annoying I've been improving it anywhere I can.
     
    Klausology likes this.
  2. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Another update just submitted. I've also updated the asset store with a couple of new videos.

     
    Klausology likes this.
  3. kbaer_nls

    kbaer_nls

    Joined:
    Oct 20, 2019
    Posts:
    4
    I stumbled across this thread because I'm looking for an alternate to Pegasus for camera motion paths.

    My use case is moving a camera through a terrain environment driving the speed from an exercise machine, like a spin bike or a treadmill. I want to create environments in tools like Gaia Pro, make paths or roads, and then add a spline camera path from a top down view, where the spline points can be set to a fixed height above the terrain surface (and be able to ignore trees and other objects when ray casting). Then I want to be able to change the speed of the camera along the path through an API. Unfortunately, Pegasus doesn't support the latter. I have been using it for a couple years assuming that I could, and now I need a new spline solution. With Pegasus, I was able to create camera paths very quickly, but it had a lot of other features I didn't need for this use case.

    BTW - I have a long history with Splines. I wrote the Mac version of Animation:Master, a spline mesh based 3D character animation DCC.
     
  4. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    I think your use case here is mostly supported. If there are any features you'd like to request I could try to add them in as soon as I can. For example, you can already place points along the surface of any mesh, but I could add in the option for "offset x units from the mesh, based on the normal" pretty quickly for you.

    Do you need help setting up a script to have a camera follow a spline, specifically? If you're comfy with some programming its fairly trivial to add in already.

    Let me know if you need anything!

    edit: actually it looks like I already added the 'offset from surface' option and simply forgot I had it in there haha. good to go
     
    Last edited: Mar 3, 2022
  5. kbaer_nls

    kbaer_nls

    Joined:
    Oct 20, 2019
    Posts:
    4
    Thanks for the quick response. I was searching other spline assets, and remembered that I had tried Spline+ for quite a while before going with Pegasus.

    If you have a camera follow script example, that'd be helpful. I'm comfortable with scripting, but haven't had a lot of background with C#, still kinda rusty. I use Swift in my day job and have long experience with C, C++, and Objective-C.

    Here's something I did with splines in 1990. The "alternate method" is Animation:Journeyman running on an Amiga 2000.
     
  6. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    That's cool! If you do pick it up, you should check out the TransformFollowSpline example script. It's a very straight forward 'make transform follow spline' helper. For something simple like a camera following a spline, this is probably all you need to get started really.
     
    Klausology likes this.
  7. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    The camera posts above made me realize it would be nice to be able to traverse of any spline at a given velocity, rather than just a given time. You could previously kind of do this by simply moving, projecting back onto spline, repeat, however this method is error prone for fast moving objects on splines with overlapping curves. So, I developed a way to simply say "get me the % of the spline based on my intended travel distance" which allows for perfect movement along a any splines at any speed, both constant and changing speeds.

    Here's a little preview:


    Code looks like this:

    Code (CSharp):
    1.  
    2. if (UpdateSplineEveryFrame)
    3. {
    4.     _splineLength = FollowSpline.UpdateDistanceProjectionsData();
    5. }
    6.  
    7. d += FollowSpeed * Time.deltaTime;
    8. d = Mathf.Repeat(d, _splineLength);
    9.  
    10. var t = FollowSpline.ProjectDistance(d);
    11. var projectedPoint = FollowSpline.GetPoint(t);
    12.  
    You might notice that for static splines, there's a cpu side savings.
     
  8. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Just pushed a new update to the asset store.

     
    Klausology likes this.
  9. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Hey wanted to give you a little update:
    I've got a working implementation of junctions in the spline system now. The way it works: When editing any spline, you can select any point and press "create junction," this will create a new spline (as a child, but this isn't necessary, it's just an organizational convenience) and automatically select the new spline. Any changes you make to the parent spline will be reflected in the starting position of the child spline. Here's a quick video of what I mean.



    In the editor, this changes of parent/child are automatically handled. However, for runtime changes you'll need to call UpdateJunction on every child spline. Maybe I should put this as a toggle? I think the developer of their game can probably determine a better place to update their junctions than I can generically make it in Update() tho.

    Can you think of any use cases you might have that this will not cover?

    (this isn't out in an update yet, I've got to clean it up a little).
     
  10. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131

    Hey corgi! Apologies for not getting back to you regarding this. I'd been completely swamped at this new job of mine!!
    I am absolutely in love with what you are showing! I really like it! I also agree that if it's a runtime change, it'd be better if the developers can just call the update junction themselves, instead of placing it in a generic update.

    I was wondering though, how would this look like if one of the splines was closed-loop? Like this:
    spline.png

    Say green spline is closed-loop, with the red spline attached to the green spline. I'm guessing there's not gonna be any difference to the video you've shown? I think you've covered the main mechanics already. Would I be right in saying that, subsequently, if we wish to say switch spline at a certain junction point, it'd be easily doable as well? Thank you very much for always maintaining this asset btw, definitely one of my favourite asset and developer out here!
     
  11. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Yes, it will be possible! I'm cleaning it up the workflow some more before pushing an update, but my intent is that you can have a start, end, or both sides of spline B junctioned to spline A. In the case you mentioned, and in this screenshot, spline A can be a closed loop and everything still works. If you want spline B to be a closed loop, it's still possible but it's likely the splines won't physically connect anymore (unless they're set to linear).

    upload_2022-3-8_7-41-29.png
     
    Klausology likes this.
  12. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Okay nice, this is exactly everything I wanted for the junctions!
     
  13. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Just pushed the junctions update! This contains all the junction stuff I've worked on so far. The only thing missing I think, is an easy workflow for actually using junctions. Right now, this is left up to the user of the plugin. If you know your junctions ahead a time, constructing a graph for your use case should be trivial. But I'll still try to get in some plugin-driven graph system in the future maybe? Not sure if this is a major desire or crossing into bloat territory.

    Documentation here, as always: https://docs.google.com/document/d/...DWV98p_H2yl-Dz8pY/edit#heading=h.jhlggh1p8ef4

    Unity_LalIe9uoqj.gif
     
    Klausology likes this.
  14. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Alright! Let me try it out once the update is out and I could let you know of my feedbacks?
     
    funkyCoty likes this.
  15. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Sounds good! Looks like the update is live now. Let me know what you think.
     
  16. kbaer_nls

    kbaer_nls

    Joined:
    Oct 20, 2019
    Posts:
    4
    I'm still confused about adding spline points. Does it support adding points to the surface of a terrain. I tried it setting Place Point Mode to Mesh Surface and Collision. Only Plane would allow me to add points. I want to be able to easily add a camera path along a terrain surface with an offset. I want to easily and add and selectively edit control points.
     
  17. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Could you give me some more info about what isn't working? Maybe a sample scene / video? If you could email me that would be great too: coty @ wanderingcorgi.com.

    For troubleshooting, my first guess is maybe you forgot to select which layers to select for collision placement? And for mesh placement, maybe it's not working because its a unity terrain? I'll look into supporting that this weekend, if that's the problem.
     
  18. kbaer_nls

    kbaer_nls

    Joined:
    Oct 20, 2019
    Posts:
    4
    I didn't have a layer for terrain, so I added one and assigned the existing Terrain to it. I changed the Point Place Mode to Collision and set the Surface Layers to my newly added Terrain. And that is working for adding points just above the surface.

    I added the Transform Follow Spine script to the camera and reset the camera's transform and set the speed constant. The camera is now following the path, but it seems to be aiming up at the sky. I have Follow Rotation selected. I'm going to create a new spline and try again.
     
  19. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    For 'follow rotation' mode, its referring to the rotation of the points within the spline. You can select them all via the inspector and press the button for 'force forward and up,' to get what you probably want. If you need something different, you can hand rotate each point if necessary.
     
  20. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Hey Corgi! I've been trying out your spline junction. I think it's very easy to use, but I am definitely unsure how I can go about getting a simple follow script going on. Say I have a Spline A (main spline), with Spline B as a junction that branches of at 0.5 percent from Spline A. I can just check what my current percentage is, and if it reaches 0.5 percent, I'd know that I've arrived at a junction. But how could I retrieve the information on which Spline is at this 0.5 percent junction so that my follow script can change spline at 0.5 percent?
     
  21. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Also, I think I must be doing something wrong here. I notice that my follower does not reach t = 1 for my splines. Here is a video showing you what i mean:



    You can also see that I am getting point index as 7 when there are a max of point index 6 on my spline. Did I set up my spline incorrectly?
     
  22. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    There's currently no automated workflow for this part yet, but I might add something for this next. For now, it's left up to the user of the plugin to manage their junctions as they need. You may need to write something to handle the graph of 'A connects to B' so a custom follower script can keep that in mind while moving over A.

    Can you either DM/email me a simple repro example? Or post your code and stuff. Is this a custom follower script or one of the built in ones? What are the settings on the spline? How is it getting t? just projecting?
     
  23. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Okay I see what you mean! Alright!

    I have sent you an email for this!
     
  24. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Small update just pushed. Fixes the issue above!
     
    Klausology likes this.
  25. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Another update:

     
    Klausology likes this.
  26. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Juicy update just uploaded.

     
  27. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Tiny update just submitted.

     
  28. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    479
    I don't know if this is a bug: When you click a spline control point, there's no way to move the gameObject that contains the spline itself unless you click another Corgi spline gameObject and then go back to the original gameObject containing the spline that you were trying to move. Clicking on nothing in the hierarchy or on another gameObject won't re-enable the ability to translate the spline gameObject itself once you click back.
    Adding to that: You can only move a spline in Self Space and not World Space. Is that desired behavior?

    Also, I know there is an API, but how simple is it to extend an open spline curve that you are traversing during runtime?
    For example: while a car is traversing a spline, is there a way to 'spawn a new point' every time you reach the end of a waypoint?
    I'd also like to know if there's a way to swap a spawned gameObject for a waypoint 'to continue the curve being traversed' for example.
     
  29. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Hmm yeah I see what you mean. This is bad UX on my part, I'll see if I can improve this. You can select "none" in the point selection in the inspector to work around this right now.

    Yeah, there's an API available with some helper functions for this stuff. For something like this I recommend either bspline or linear mode and to just use spline.AppendPoint() for adding points (you can use bezier too, but you have to manage the points and handles so its a bit more complicated). The AppendPoint() stuff takes in a Vector3 position so you can use whatever you want to spawn it.
     
    Frpmta likes this.
  30. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    479
    I did try that and it didn't work.
    And now it works.
    Seems I had Spline Space set to World when I tried it originally.

    In the moving cars example, I notice If I move pointB while a car is moving between pointA and pointB it will deviate from the path. That means the rigidbody spline behavior is more like an approximation and there is no way to make it follow the path exactly, right?

    Also, what is the exact use of ProjectionTester?
     
    Last edited: Apr 19, 2022
  31. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Sorry, I was referring to your issue with not seeing the Transform handle when a spline point was selected, not to your other issue of not being able to move the spline points via the Transform handle. It's intentional that you cannot move all of the spline points when in World space. Would you like this as an option?

    There's a couple different follower examples in the project. One moves transforms directly to show how to keep things directly tied to a spline. The rigidbody example is meant to show how you can approximate following. Take a look at a few of the examples to see how to do either. It's definitely possible to have a rigidbody completely attached to a spline. The transform example also goes the extra mile to show you how to do things "distance" based rather than percentage based, so you can modify the spline and not move the objects following the spline too far.

    But with what you've explained, I think you'd be better off just reprojecting every time you add a new point, so the position is completely stable. Something like "new position = spline.Project( current position );"

    It's mostly for debugging, but I left it in, in case anyone has any use for it themselves. It's also a simple example of API usage.
     
    Frpmta likes this.
  32. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Pushed another update:

     
    Westomopresto likes this.
  33. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Update incoming:

     
    Klausology likes this.
  34. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Small update just pushed:

     
  35. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Small bug fix update incoming:

     
  36. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Another small bug fix update just pushed to the store.

     
    iddqd and Klausology like this.
  37. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Update coming through! Preview video of the new functionality here: https://uploads.coty.tips/Unity_9AdUQySv23.mp4

     
    Klausology likes this.
  38. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    479
    The API documentation is very barebones.
    If I have a list of points in an array and want to create a Corgi Spline out of them, what do I have to do?
     
  39. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    The easiest and most straightforward way is to convert your Vector3[] to SplinePoint[] and just set it directly to the Spline.

    MySpline.Points = MyPoints;

    Alternatively you could iterate over your Vector3 array and just call MySpline.AppendPoint() over and over.
     
    Frpmta likes this.
  40. Hogfather

    Hogfather

    Joined:
    Aug 17, 2010
    Posts:
    44
    One of the things that lured me towards Dreamteck splines was the ability to use an array of meshes to be both stretched or placed along the spline, using a set seed value which gives both variety and repeatability.

    Is that something that would be possible with Corgi Splines? In all the videos I've only seen one mesh being used, so it might be something already implemented that I just didn't manage to find.
     
  41. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    At the moment you can use one mesh, yeah. If you want me to add the option for multiple meshes, I can look into getting that in for you.
     
  42. Hogfather

    Hogfather

    Joined:
    Aug 17, 2010
    Posts:
    44
    Just purchased Corgi Splines just for this reply :)

    I would be grateful if you could and still happy with my purchase if you find out you can't.
     
    funkyCoty likes this.
  43. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Hey just a small update, wanted to let you know I got a chance to attempt adding support for multiple repeatable meshes along a spline this weekend. I think I came up with a clever way to do it and still be Burst friendly, so after a bit of cleanup I'll be pushing this as an update. Here's a little preview:

    upload_2022-11-5_23-23-23.png

    It'll have some limitations (size along z axis must match + you want to have pretty much the same type of data in all the mesh variants) but I think this will be pretty useful.
     
    Hogfather and iddqd like this.
  44. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    This update is ready to go! Just submitted to the asset store:

     
  45. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Great stuff, thank you!
     
    funkyCoty likes this.
  46. Hogfather

    Hogfather

    Joined:
    Aug 17, 2010
    Posts:
    44
    Thank you so much.
     
    funkyCoty likes this.
  47. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Small update coming through:

     
    Klausology likes this.
  48. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Another small update:

     
    Klausology likes this.
  49. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    A bit of a meatier update coming through, as per request of some users.

     
    Klausology and iddqd like this.
  50. cranecam

    cranecam

    Joined:
    Nov 25, 2013
    Posts:
    25
    Is there a sample API usage somewhere?