Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

SplineMesh, the plugin to create curved content

Discussion in 'Assets and Asset Store' started by methusalah999, Dec 14, 2017.

  1. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    57
    Ok. For now it looks like I haven't broken anything.
     
  2. RowelCaps

    RowelCaps

    Joined:
    Jun 2, 2018
    Posts:
    4
    Does this work for unity 2019?
     
  3. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    SplineMesh works with all version of Unity from 5.6, and all render pipelines.
     
  4. RowelCaps

    RowelCaps

    Joined:
    Jun 2, 2018
    Posts:
    4
    I just tried it now, Looks really great! I love it!

    Thank you so much!
     
    methusalah999 likes this.
  5. tronixx2025

    tronixx2025

    Joined:
    Apr 26, 2021
    Posts:
    3
    Hi, this asset is pretty cool thank you for making it. I'm trying to run my game but I can't due to this error I have and I'm not sure how to fix it at all. Is there any way you can help?


    https://ibb.co/DrQPGZz

    https://ibb.co/hDDfv93

     
  6. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    The source code sell to be changed on you side. Try to reimport the asset
     
  7. tronixx2025

    tronixx2025

    Joined:
    Apr 26, 2021
    Posts:
    3
    I tried that already but it didn't work somehow, for this particular game the "SplineSower.cs" code is needed to work so it can compile for one of the objects it uses. I also tried fixing the code myself, but no luck. I get the same or more errors when I alter the code.
     
    Last edited: May 1, 2021
  8. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    You are just using the namespace SplineMesh instead of the class Spline. Just replace SplineMesh by Spline in your code, and add a using for SplineMesh namespace in your header.
     
  9. tronixx2025

    tronixx2025

    Joined:
    Apr 26, 2021
    Posts:
    3
    Ah ok, how do I do that? I'm a beginner at coding and on Unity as well. I have Visual Studio open to alter the code.
     
    Last edited: May 1, 2021
  10. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    840
    I had a question for you. Does this asset have, the ability to wield procedurally an actually mesh, to a spline. Best example. In Maya, we use splines to create most trees, and so forth, but we manually wield them to our scanned meshes.

    So, I see you have some really nice procedurally splines. So being able to merge/wield splines to meshes, would be nice. Its something I had worked on for a bit now and a few others I know. I seen a few tools close to what we been looking for that we made or worked with.

    This one seems like its possible.? any info would be great./

    so my question is, is this asset able to wield a spline to a mesh. at all?

     
  11. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    Sorry I'm not sure I understand. Are you talking about the linking of the meshes, that occur at 0:19 is the video, and is called "weld meshes together"? If so then no, SplineMesh does not provide anything to get such a result unfortunately.
     
    Recon03 likes this.
  12. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    840

    Ya. Thanks for that info.
     
  13. ryansizemore

    ryansizemore

    Joined:
    Jan 25, 2014
    Posts:
    8
    Thank you so much for this, it has been an awesome tool for a project that I'm working on.

    I'm trying to figure something else and was wondering if you are someone could give me some advice. I want to set a trigger to a spline node so I can move it and distort the curve in realtime. I don't know how to call nodes in code to transform them, but if I can add a collider that might work too.
     
  14. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    You can move node in real-time like this
    spline.nodes[nodeIndex].Position = newNodePos;
    . Same goes for the Direction and all the other properties.

    If you are using the SplineMeshTiling component, then you will need to check "update in play mode" option so your content is updated after the node change.

    If you want to use a game object as a node position, you will have to write a one line script for this object to give its positions to the node in each update. This can be useful to animate nodes, or have them following rigidbodies moving with physics.
     
    NameOfTheName likes this.
  15. ryansizemore

    ryansizemore

    Joined:
    Jan 25, 2014
    Posts:
    8
    Great, thank you!
     
  16. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    57
    How are the UV maps of the meshes generated with SplineExtrusion? I'm using a tool that paints on the texture of gameobjects and it requires well-formed UV maps to work, but when I try to visualise the uv mapping of the segment meshes using the tool's mesh analyser it reports that none of the triangles have UV values associated with them.

    With the VS debugger I checked the components of the mesh object directly in the code, and while it seems it does have a populated UV array, all the x values are 0, so I'm a bit confused.

    Can you shed some light on how to get appropriate UV maps for the individual segment meshes of shapes extruded with SplineExtrusion?
     
  17. fweibel

    fweibel

    Joined:
    Oct 16, 2019
    Posts:
    2
    Hi! I noticed that SplineMesh wasn't copying the colors of the vertices, so I modified the script to support that! Let me know if you are interested to get the files to include that into the original codebase.
     
    methusalah999 likes this.
  18. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    Sorry for the late answer. With the SplineExtrusion component, you can (and should) set U coordinate in the shape vertices list from the inspector. It is zero by default. V goes from 0 to 1 along the spline length. You can scale this differently using the property textureScale.

    You can find the assignation of the texture coordinate in Extrusion segment class, Compute() method, at line 177 here.

    Have fun !
     
  19. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    Of course, you can send a pull request on SplineMesh github repository if you want. Though I don't have much time to work on this asset at the moment.
     
  20. fahruz

    fahruz

    Joined:
    Mar 5, 2020
    Posts:
    57
    I see. Thanks.
     
  21. lucidtripper

    lucidtripper

    Joined:
    Aug 3, 2017
    Posts:
    22
    This asset looks amazing !

    I've loaded the asset - the samples work fine - but all the controls are greyed out

    I just need "follow a spline" option 10 in your samples

    - can u include a previous version for 2020.2.0f1 ? we're not ready to switch to 2021

    - wait - I found a previous version on your github - will test it now
     
    Last edited: Jun 9, 2021
  22. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    SplineMesh is compatible with all versions of Unity since 5.6. What do you mean "controls are greyed out"? can you please make a screenshot? Can you also try to reset your Unity layout and see if it fixes the issue (it's in "Window => Layout => Reset all layouts", don't forget to save your layout first)?
     
  23. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,510
    I exported to webgl and for some reason the follow contortion does not do anything, the models just stays in place.
    In the editor it works but not in the webgl build.
    Is this a known issue?
     
  24. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    Indeed, most examples uses the editor refresh clock and not the actual game update, so you can see things moving without having to run the game ^^

    Just go into the code and change the method name "EditorUpdate" by the classic Update. Remember that all files named "Example" are only source of inspiration for you to write your own scripts, and should not be used as is in your project.
     
    Lars-Steenhoff likes this.
  25. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,475
    Hi, I like this asset, looks really nice! Can I ask for some guidance on how to make a spiral shape mesh with this spline tool, kind of like the thread of a screw? Would welcome any ideas on this, as drawing the spline like this manually seems quite difficult.
     
  26. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    There are a number of ways to do that. For example you can :
    • have node 1 to the east (1, 0, 0) with its direction to the north (1, 0, 1),
    • have node 2 higher, to the west (-1, 0.1, 0) with its direction to the south (-1, 0.1, -1),
    • have node 3 above node 1 (1, 0.2, 0) the same direction (1, 0.2, 1),
    • and so forth.
     
  27. Wyvernn

    Wyvernn

    Joined:
    May 25, 2017
    Posts:
    3
    I had this problem where "Add node after selected" and "delete selected node" were both grayed out.

    I was using a custom Layout, I changed it to the default layout and back again and the controls are no longer grayed out. So that fix seems to work.

    This was with Unity 202.3.12f1.
     
    Object-Null and theclimbingguide like this.
  28. GordGames

    GordGames

    Joined:
    Nov 7, 2016
    Posts:
    32
    Hi there,

    I'm using spline mesh to dynamically create a pipe behind a drill the player controls. This is what it's doing:

    drill2.gif

    So far so good but I did some hacky things to prevent gimbal locking and also added some code to SplineNode.cs. Is there a better-supported way to do it? Because the pipe went straight down, I had to change "UP" to all zeros or else I got twisting.

    Code (CSharp):
    1. public SplineNode(Vector3 position, Vector3 direction, Vector3 up)
    2.         {
    3.             Position = position;
    4.             Direction = direction;
    5.             Up = up;
    6.         }
    In my game I call it like this:
    Code (CSharp):
    1. if (Vector3.Distance(this.transform.position, pipe.nodes[pipe.nodes.Count - 1].Position) > distanceBetweenNodes)
    2.         {
    3.             //add a new node
    4.             pipe.AddNode(new SplineNode(this.transform.position, pipeDirection.transform.position, Vector3.zero));      
    5.         }
     
  29. TangZeJiang

    TangZeJiang

    Joined:
    Dec 16, 2020
    Posts:
    2
    I have a problem. res is null,I went the break point and found that this is really upload_2021-8-4_16-34-18.png
     
  30. TangZeJiang

    TangZeJiang

    Joined:
    Dec 16, 2020
    Posts:
    2
    I found this problem solved itself after resetting the layout:confused:
     
    twobob likes this.
  31. TheuerkaufLaurenz

    TheuerkaufLaurenz

    Joined:
    Apr 5, 2018
    Posts:
    5
    Hi,
    i really like the Asset, but i have one issue, maybe you can help with that.
    When I'm moving my parent object, where the Spline Mesh is attached to, the Mesh is staying at its original location. Did I overlook something, or isn't it possible to move the spline at runtime?
     
  32. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Thanks for this. very useful.
     
    methusalah999 likes this.
  33. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    upload_2021-9-1_15-38-19.png
    Like EXTREMELY useful
    Insanely useful
    upload_2021-9-1_15-39-40.png
    Pretty much converted a /meh/ tool into an awesome tool. So. Yeah. many thanks
     
  34. Cyril_m

    Cyril_m

    Joined:
    May 11, 2017
    Posts:
    3
    Hi!!

    First of all, I want to say THANK YOU for making and sharing such a useful tool. It's exactly what I needed so it's a huge time saver. Also, having a free version is much, MUCH appreciated, especially when you're starting out and you're not sure where you're going with a project and your budget is basically 0 bucks haha I hope I'm able to support in the future, so having the option to do so is pretty neat.

    That said, I think I might need a bit of help? Hope that's ok!

    I've been trying to make some growing vines using the exemple growing root script; they're basically slithering upwards, I'm planning to make them climbable (like ladders, that part is ready). It's working well, but the issue I'm encountering is I can't seem to be able to make them bend more smoothly? They appear jagged, with multiple visible sections.

    12.png

    I managed to make smoother vines without the growing script, using the tiling one, but using the 2 doesn't seem to be working for me I tried tweaking the nodes but couldn't get the result I'm looking for. Any idea what I should be looking into? I've been racking my brain so any input would be super appreciated Thanks again!!

    Edit: using a more detailed cylinder mesh seems to be doing the trick, but I'm getting a massive performance hit during the growing phase (then it's all good afterwards) so if there's a better solution I'm all ears!
     
    Last edited: Sep 2, 2021
  35. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    well. you just need more "edges" (vert locs), cylinders got too many, that doesn't have enough. find somewhere in the middle?
     
    Cyril_m likes this.
  36. Cyril_m

    Cyril_m

    Joined:
    May 11, 2017
    Posts:
    3
    Yes that's what I was thinking too. I'll give this a shot at some point, thanks! (moved onto something else for now)
     
    twobob likes this.
  37. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    If you simply add more vertices you will indeed get better definition along the vine, but it will quickly come at the cost of the performances.

    The solution depends widely on what you want. For example, if the bottom part of the vine is not growing anymore, and only the tip is expanding, then you can grow the curves individually, one after the other. This way, only the curves at the tip are updated, while the curves at the base are not changed anymore and don't impact the perfs

    On the contrary, if the base needs to continue and slowly grow to become thicker and thicker for example, you can create a script that will change the thickness of these curves only sometimes and not at every frame. It shouldn't be noticeable because the thickness grow slower and slower over time, and it will save a lot of perfs. For example, the three curves at the tip are updated every frame, but the 4th is only updated one frame out of 2, the 5th one out of 3, the 6th one out of 4, etc.

    For all of this, you will have to create your own script but relax, SplineMesh is designed exactly for this and writing your own script is pretty easy. All the hard work is done in inner classes.

    Have fun and share your progress!
     
    twobob and Cyril_m like this.
  38. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Welded directly into MapMagic2, just pick a prefab to string along SplineSowers.
    upload_2021-10-8_17-45-34.png

    Multi random prefab support
    upload_2021-10-8_19-6-8.png

    Sower configuration from interface
    upload_2021-10-9_4-44-54.png

    Thanks.
     
    Last edited: Oct 9, 2021
    one_one, ledshok and methusalah999 like this.
  39. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    upload_2021-10-10_3-46-55.png

    Spline mesh rendering the world map inter-city paths
    upload_2021-10-10_3-49-49.png

    (And everything else not nailed down..,)

    It does a good line in dotted lines...
    upload_2021-10-10_5-13-30.png

    Getting a lot of Viewing vector is zero and sense the need to change up the Update logic to check for a logical node count before being "enabled" since these are now created purely in script.
     
    Last edited: Oct 10, 2021
  40. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    This can happen when two nodes are overlapping ^^

    Great job!
     
    twobob likes this.
  41. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Ah good tip thanks. I'll dig around and try to add some "normal tests" to prevent 0 angle node incidence then

    upload_2021-10-10_11-47-57.png

    Used to render out directional footsteps along a path ;) (cos why not)
     
  42. homer_3

    homer_3

    Joined:
    Jun 19, 2011
    Posts:
    111
    Hi, awesome asset! Thanks for providing it and supporting it so extensively. From looking at the demo scene, it seems all splines are pregenerated. Is it possible to create splines at runtime to extrude meshes from? If I play a scene, create a spline, I get a bunch of errors and can't even navigate the scene view. I was hoping to create curving beams fired from the player using this tool, so I'd need to generate the splines and meshes during gameplay. Does the tool support something like that?
     
  43. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    639
    SplineMesh is designed to update both in the editor and in play mode. This allows you to get your generated content right in the editor to compose your scene and bake the lights, while also being able to animate a curved object in your game.

    SplineMesh is also capable of knowing what must be updated and when so you don't have to bother about it. That said, you don't want SplineMesh to rebuild your content when the game start if the content from the editor is enough. It would cost useless process time and may brake your baked light maps. So in SplineMeshTiling, you have to explicit what object will have to update during play time by checking the option "update in play mode".

    Finally, it is ok to create a new spline during play time even if there is no example of that in the showcase scene. This will require that you created at least two nodes (which are created automatically for you in the editor through the Reset method) and have a good understanding of the node placing to get an actual bezier spline. You should be able to easily understand the errors you have, but you can also paste them here for a feedback.

    Have fun bending things!
     
    twobob likes this.
  44. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Someone asked for me to rip the MapMagic custom OUTPUT I wrote for SplineMesh (requires the OBJECTS plugin for mapMagic since that is how the prefabs are currently handled internally.) into a separate Repo.

    This thing here on the left
    upload_2021-12-30_15-13-29.png

    It's not pretty, just a one to one UI for ExampleGrower. It's not clean, simply ripped all the required guts to "make it work"; One could very easily junk 30% of the code in here most likely but it shouldn't hurt anything ligging around if no-one can be bothered.

    Anyway, caveats and junk warnings aside
    https://github.com/twobob/SplineMeshAsMapMagicOutput#readme
    Anyone... feel free to improve on that. Pulls welcomed.
     
    Last edited: Dec 30, 2021
  45. Ganicuus

    Ganicuus

    Joined:
    Jan 24, 2021
    Posts:
    6
    Hey, does anyone have a problem with adding nodes? I have button for add nodes grey(disable). Im using 2019.4 LTS.
    upload_2022-1-4_21-28-36.png
     
  46. Ganicuus

    Ganicuus

    Joined:
    Jan 24, 2021
    Posts:
    6
    I figured it out. I found that the Add Nodes button has a problem with my layout, so if you want to use this plugin, I recommend the default layout.
     
    ryansizemore likes this.
  47. oen3

    oen3

    Joined:
    Aug 16, 2021
    Posts:
    18
    I have the same issue, (nodes are gray and I cannot edit the splines). I dont see it working even after resetting layouts to default. I'm on 2021.2.8
     
  48. ryansizemore

    ryansizemore

    Joined:
    Jan 25, 2014
    Posts:
    8
    Thank you, I was going insane trying to figure out why this wasn't working for me anymore. That fixed it.
     
  49. VitruvianStickFigure

    VitruvianStickFigure

    Joined:
    Jun 28, 2017
    Posts:
    38
    I just picked up SplineMesh today, and am loving it; but I'm having a hard time understanding how to adjust the control points in code. It seems to have something to do with
    Direction
    for a
    SplineNode
    , but no matter what I do my spline seems to be overshooting its target during run time.

    (I'm specifically working on a system where a player runs a wire between nodes; the second node of a two-node spline is locked to the player's position, the other to the origin point. When I'm running, I would like the spline to ease to a stop at the player, maybe with a little realistic curvature of maybe 15°; but it consistently shoots past the player, and the farther out I go, the farther the overshoot.)

    My current code, comments and all for clarity, looks like this:
    Code (CSharp):
    1.     void Update()
    2.     {
    3.         //This should perhaps also contain a path to a sub-transform.
    4.         NetworkIdentity player = NetworkClient.localPlayer;
    5.        
    6.         if(player != null) {
    7.             SplineNode start = spline.nodes[0];
    8.             SplineNode end = spline.nodes[spline.nodes.Count - 1];
    9.            
    10.             //Update position of last spline to match target transform
    11.             Debug.Log("Node Count: " + spline.nodes.Count);
    12.             Debug.Log("Node: " + end);
    13.             end.Position = player.transform.position;
    14.            
    15.             //Update angle of last spline to match delta
    16.             Vector3 diff = (transform.position - player.transform.position).normalized;
    17.             //rotate 30° clockwise
    18.             //start.Direction = Vector3.zero;
    19.             start.Direction = Quaternion.AxisAngle(Vector3.up, 180f+30f) * diff * 0.1f;
    20.             //end.Direction = Vector3.left;
    21.             //end.Direction = Vector3.zero; //Quaternion.AxisAngle(Vector3.up, 180f) * diff * .1f;
    22.         }
    23.     }
    24.  
    I'm probably missing something basic, I get that control points are defined by
    Direction
    , but I'm not sure how. There isn't much documentation on what exactly "direction" means yet. Could someone help me out?

    Also, are there any plans for a wiki or some proper documentation for this lovely asset?
     
  50. Object-Null

    Object-Null

    Joined:
    Feb 13, 2014
    Posts:
    70
    Just what i was looking for.
    same happens to me. your solution worked