Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Bézier Path Creator (free)

Discussion in 'Assets and Asset Store' started by SebastianLague, Feb 3, 2019.

  1. SebastianLague

    SebastianLague

    Joined:
    Aug 31, 2014
    Posts:
    111
    Hello, I've created a tool to quickly and easily creating paths for your game. You can make objects move along these paths, or use them as a guide for spawning objects and generating meshes.

    You can download it for free from the asset store.
    See the user guide for a full run-down of the features, or have a look at the video below for a quick overview.
    I hope this will prove useful to some of you!

     
  2. Kellyrayj

    Kellyrayj

    Joined:
    Aug 29, 2011
    Posts:
    926
    Super excellent tool! Thank you for sharing.

    I am trying to understand how I can modify the tool to be able to see the path in the editor when I don't have the path selected. any clues as to how I could make this happen?
     
    pabler343 likes this.
  3. SebastianLague

    SebastianLague

    Joined:
    Aug 31, 2014
    Posts:
    111
    Hi, if you get the latest version from my github you can enable this as an option in the path settings. https://github.com/SebLague/Path-Creator
     
    Kellyrayj likes this.
  4. Kellyrayj

    Kellyrayj

    Joined:
    Aug 29, 2011
    Posts:
    926
    Hi @SebastianLague! Thanks for your speed reply before.

    I've another question for you. I've created a follow path script very much like your example. I'd like to be able to send Unity Events based on where an object is on the path. For instances, if the end of path instructions is set to stop, I'd like to be able to send an event when the object reaches the end of the path. Thoughts on how I can go about doing this?
     
  5. VanDraven

    VanDraven

    Joined:
    Oct 31, 2012
    Posts:
    6
    Hi, you've made a great tool! I've even signed up to your Youtube channel!
    It seems the path is locked in place, is there a way to move it with the object the script is attached to?
     
    Last edited: May 17, 2019
  6. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    683
    Thank you so much for making this tool, it saved me a tremendous amount of time and frustration. :)

    It's probably far outside the scope of what you had in mind, but do you have any suggestions for how we could go about merging meshes if we wanted to have multiple paths cross over each other or form intersections without z-fighting?
     
  7. rudomanenkoanton

    rudomanenkoanton

    Joined:
    Jun 27, 2019
    Posts:
    1
    It seems like there are some mistakes in documentation. When I want to create path from script I use method GeneratedPath from doc. But if I convert bezier path to Vertex path, like in documentation, I get the error message, that Vertex path constructor get more than one parameter.
     
  8. Balours

    Balours

    Joined:
    Nov 27, 2013
    Posts:
    52
    Hi, is there a way to change the color of a curve in the editor without changing the color for every curve?
    Thanks!
     
  9. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    26
    This is excellent. I'm just wondering, is there a way to set a point's transform as a GameObject's transform? That way, the path constantly updates to follow a moving GameObject's transform.
     
  10. Linsky

    Linsky

    Joined:
    Mar 27, 2017
    Posts:
    1
    Is there a way to make the object to stop at a certain point and keep going after a key is pressed?
     
  11. meuklight

    meuklight

    Joined:
    Feb 2, 2016
    Posts:
    11
    Very nice and useful asset! Thank you so much!
    Can I create a Bezier Curve and Vertex Curve once and only update the points position other time?
     
  12. unity_VMhu5_JGYBnyOg

    unity_VMhu5_JGYBnyOg

    Joined:
    Jan 4, 2020
    Posts:
    1
    Hello, thank you very much, it is very nice and useful. I have a question with creating path by script, can I update the path? and how can i do that (with script)
     
  13. Fimiam

    Fimiam

    Joined:
    Oct 24, 2016
    Posts:
    9
    Hello, it's really awesome tool!
    Can anyone share a script to align two bezier paths with each other and smooth angles?
     
  14. hhamedware

    hhamedware

    Joined:
    Feb 8, 2019
    Posts:
    3
    hi,
    thanks for this path SebastianLague,
    but i want to know is there way to deactivate and activate this path when i need it or change the path to another path by script.
    thank you.
     
  15. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    117
    Does anyone know how can I tell if my transform has reached the end of it's movement along an open path?

    I have tried all sorts of ways (that didn't work) but I was sure there is probably a simple conditional or callback that can be used.

    I am using (from the documentation) the following in my Update routine:

    Code (CSharp):
    1. if (pathCreator != null){
    2.             distanceTravelled += speed * Time.deltaTime;
    3.             transform.position = pathCreator.path.GetPointAtDistance(distanceTravelled, endOfPathInstruction);
    4.         }

    This all works perfectly but I would like to know when my transform has reached the end of the path. Anyone have an idea what I should be doing?
     
  16. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    169

    Just check if the distance traveled is greater than the total length of the path.

    Code (CSharp):
    1. void Update()
    2.         {
    3.             if (pathCreator != null)
    4.             {
    5.                 distanceTravelled += speed * Time.deltaTime;
    6.                 transform.position = pathCreator.path.GetPointAtDistance(distanceTravelled, endOfPathInstruction);
    7.                 if(distanceTravelled>=pathCreator.path.length)
    8.                 {
    9.                     //reached end
    10.                 }
    11.             }
    12.         }
     
    Last edited: May 26, 2020
    haidersquadcell and glander56 like this.
  17. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    117
    Thank you @Aseemy ! That works perfectly. Simple and elegant. :)
     
  18. pabler343

    pabler343

    Joined:
    Apr 23, 2020
    Posts:
    1
    Did you have a answer? Y have the same problem
     
  19. rhyswittingslow

    rhyswittingslow

    Joined:
    Feb 24, 2016
    Posts:
    7
    Anyone know if there's anyway to check what point an object thats following the path is at?

    And to have one point branch off to two points?

    Or set each point to have an action, say freeze the movement on the path.
     
  20. Mike-Foregger

    Mike-Foregger

    Joined:
    Dec 3, 2015
    Posts:
    2
    Is it possible to see the path in the game view so it looks similar to the editor?
     
  21. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    169
    you can use a line renderer for that
    get the points of the path and set them in the line renderer
    adjust the line renderer to match the look and feel you want
     
  22. juanscigliano

    juanscigliano

    Joined:
    Aug 14, 2020
    Posts:
    1
    Somebody could make a Rigidbody follow a path? Im trying to accomplish this in a 2d enviroment.
    Cheers.
     
  23. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    169
    you can set the rigidbody as kinematic and use MovePosition method of the rigidbody to follow the curve.
     
    juanscigliano likes this.
  24. SpaceSim

    SpaceSim

    Joined:
    May 15, 2020
    Posts:
    3
    why is my object scaled up when i press play? And it also sits way above the path. If i scale it to 0.1 in INspector and i press play the object goes back to scale 1, starts following the Path but it is clashing with walls.
     
  25. Kerphelio

    Kerphelio

    Joined:
    May 28, 2020
    Posts:
    1
    Fantastic tool, thanks for making it available!
    I'm wondering, is there a way to manipulate the shape of an existing path, aka anchor and control points at run-time via script? I did find SetPoint() in the Bezier path, but I'm not sure if changing it at runtime will actually affect the underlying vertex path so I'm wondering if there is a good way to do this. I have been able to eg. read points in from a text file, but while it works "visually", the objects attached to the path will still be following its old shape.
    Only workaround I've found is to instantiate the path after making changes directly to the prefab. Maybe a problem with how the vertex paths are generated? Do I need to manually trigger that somehow?
    What I'm trying to do right now is to move the second-from last anchor point of a path to the position where the player starts, but this position might change, so I'd like to make it so that it adjusts automatically to the pos of the player object when the game starts. I'm sure I could make some complicated contraption where I re-create the entire path from a script, but that sounds like a bit of overkill to just change one little point ;)
    Thank you!
     
    Last edited: Sep 30, 2020
  26. oleh_baziv

    oleh_baziv

    Joined:
    Jan 3, 2018
    Posts:
    3
    Hi @SebastianLague , I have some problems with road generation, I perform path generation, and the road is not updated, but when I click on a game object, then the road is updated, what's the problem? how do i update the road to not click on the game object?
     
  27. neetesh6499

    neetesh6499

    Joined:
    Dec 24, 2014
    Posts:
    8
    For anybody looking to achieve the same thing as @Kerphelio mentioned, here's my workaround ( This is by no means the best way to do this, however after searching & experimenting with the code for about a day I was able to figure this working method )

    pathCreatorScript.bezierPath.SetPoint(0, transform.position, false);
    vertPath = new VertexPath(pathCreator.bezierPath, pathCreatorScript.transform);

    First set the Bezier path point, using the new Bezier path you need to create a new vertex path. This will achieve changing the point & the object following the new path. However the Bezier path line won't be updated in the scene view ( unless selected ) which I wasn't able to achieve.

    I'm using this inside a trigger in my project so I can't say if this will have a performance impact if you're doing it in update or so. However for those looking to make it work in more simple scenarios. Hope this helps :)
     
    Kerphelio likes this.
  28. cool_clem

    cool_clem

    Joined:
    Feb 12, 2017
    Posts:
    1
    Hi @SebastianLague ! Very nice tool, thank you for sharing it.
    I'm prototyping something where I need my path to be updated at runtime (I'm adding and deleting segments). I've got everything set up and working but with one issue : My path needs to be selected when entering into play mode for it to be properly updated at runtime. On the other hand, once started I can select anything else in my scene my path will still update.
    Any tips on what could I do to not have to select my path before each time I want to go into play mode ?
    Thanks !
     
  29. Sidadi657

    Sidadi657

    Joined:
    May 15, 2020
    Posts:
    2
    @cool_clem I want to know how to make the path update in runtime
     
  30. Hodja

    Hodja

    Joined:
    Sep 17, 2020
    Posts:
    1
    Please how can i restart my follower
    object?
     
  31. Jointy87

    Jointy87

    Joined:
    Dec 19, 2019
    Posts:
    13
    Hiya,

    First of all, super thanks for sharing this tool with the world! Great stuff!

    But the tool seems broken for me. Whenever I try to create a path, it's not visible in the editor. Only if I DON'T have it selected, does it become visible, but still without handles and points, just the line.

    If I go to the example scenes that come with the package, the same issue persists with the paths in there.

    If I create a completely new unity project with the same version as the project I actually want to use the paths in, the path DOES work fine. So weird.

    I'm using Unity 2020.1.9f1.

    I'm super keen on using your tool for my project, it's so perfect for it. I'm really hoping I can get it to work. Do you have any idea what the problem could be?

    Thanks in advance
     
    Last edited: Dec 22, 2020
    gaelleBe and konradwerys like this.
  32. Roboserg

    Roboserg

    Joined:
    Jun 3, 2018
    Posts:
    50
    How do I iterate over the handles / nodes of a Bezier curve? The nodes we are moving with the mouse
     
  33. Crawdad

    Crawdad

    Joined:
    Nov 23, 2016
    Posts:
    47
    Hi, Sebastian. Just wanted to say this is a really amazing tool. I've been following your Youtube page for a while, and am always impressed with your work. You have a real knack for making really difficult concepts accessible for dabblers like myself.

    I would like to point out one thing that I feel would help extend this tools versatility. It would be nice to have some way to easily update the anchor points positions during runtime. Maybe make the anchor points child objects, so the transforms are easier to access for dummies like me. I originally downloaded this hoping it would be a good solution to easily launch objects from one point to another on a given path, but without the ability to manipulate the anchors during runtime, it isn't really suited for that. I appreciate that is not really what this tool was designed for, but it would be a nice perk.

    Anyways, thanks again for all that you do. Keep up the good work.
     
  34. thedejavu

    thedejavu

    Joined:
    Feb 4, 2021
    Posts:
    1
    Hello Guys. The object on Path doesnt effect from any collision.How I can solve this problem ? I mean I can not use OnCollisionEnter method for this.Help please.Thx.
     
  35. gaelleBe

    gaelleBe

    Joined:
    Nov 6, 2020
    Posts:
    8
    I have been using Path creator on a project, unity 2020.1,HDRP 2.8.0, and it worked fine. Now I am building another with identical settings, and the path doesnt show. I rtied an imported the 3d object with the path component, and it works, without showing on the scene. Is there something to fix it?

    **EDIT*** The guismo were hidden, so was the path!
     
  36. malcolmregan

    malcolmregan

    Joined:
    Feb 12, 2021
    Posts:
    1
    Having this issue as well. I have a script which updates control points every frame, but it only updates in play mode if the gameobject holding the pathcreator script is selected. If anyone knows the solution to this problem please share.
     
  37. icecold043

    icecold043

    Joined:
    Jan 9, 2019
    Posts:
    8
    Still no way to make a point follow a game object? By making it a child, or using a script?
     
  38. laditanpelumi

    laditanpelumi

    Joined:
    Mar 14, 2021
    Posts:
    1
    Hello guys,
    I downloaded this package from the unity asset store and I am trying to follow the scripting tutorial but I keep getting the following error:
    "The type or namespace 'PathCreation' could not be found (are you missing a using directive or an assembly reference?)"
    From my googling so far, apparently the PathCreation namespace should be in the Assets/Plugins folder before I can access it in the script. How do I go about fixing this? Thanks for your help
    PathCreator.PNG
     
  39. the_cerberus

    the_cerberus

    Joined:
    Aug 20, 2019
    Posts:
    9
    Hello,
    i use Path Creator for a RailShooter. It realy works fine, but i have an issue with the Normals. When i use the PathCreator for a 3d Path, the camera is orientated by the normal. In some situations this is not good. How can i disable the normals?
    Thanks
     
  40. walir999

    walir999

    Joined:
    Nov 2, 2020
    Posts:
    1
    Hi, did you find the fix to this problem? Im stuck on this as well
     
    Last edited: Mar 28, 2021
  41. romi-fauzi

    romi-fauzi

    Joined:
    Aug 16, 2013
    Posts:
    154
    For anyone having issues with updating the spline on runtime without being selected first, here is a solution:

    Code (CSharp):
    1.     private void OnEnable()
    2.     {
    3.         path.bezierPath.OnModified += UpdatePath;
    4.  
    5.     }
    6.  
    7.     private void OnDisable()
    8.     {
    9.         path.bezierPath.OnModified -= UpdatePath;
    10.  
    11.     }
    12.  
    13.     private void UpdatePath()
    14.     {
    15.         path.bezierPath = path.bezierPath; //force bezier path to update
    16.        
    17.         path.GetComponent<PathCreation.Examples.RoadMeshCreator>().TriggerUpdate(); //force road mesh to update
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.         path.bezierPath.MovePoint(id, endPoint); //move the n point to a vector3 called endPoint in inspector
    24.     }
    And upon updating the path, you can also trigger update for the road mesh component, this will also update the mesh.

    Hopefully this helps!
     
unityunity