Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bézier Path Creator (free)

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

  1. resw

    resw

    Joined:
    Jun 30, 2018
    Posts:
    1
    Thanks, I have been experiencing this problem. It really helped a lot.
     
  2. Sk8aaron

    Sk8aaron

    Joined:
    May 3, 2020
    Posts:
    1
    How would I use this path with physics such as "Addforce" to throw it along the path going from point to point with inertia? For example in a skateboarding grind with curvy rails.
     
  3. MickLil

    MickLil

    Joined:
    May 13, 2019
    Posts:
    1
    I've got a rather noob question? How do I know which end of a path is the start? If I'm moving an object along the path, this will dictate the direction it goes. Sure, I could create one the use some code to get the position via pathCreator.path.GetPointAtDistance but I'd have to do that for every single path.
     
  4. TDP_

    TDP_

    Joined:
    Oct 14, 2020
    Posts:
    7
    I wanted to use this to create a curve between to points, as to smooth out the moving of an object. This is not supported by default but the core scripts are well commented, allowing me to find what I needed to set my own control points upon generating a path via script. It didn't take me longer than an evening to find the right variables and set it up with my game. Thanks for making my life easier!
     
    mishakozlov74 likes this.
  5. MlleBun

    MlleBun

    Joined:
    Sep 19, 2017
    Posts:
    163
    Hi @SebastianLague ! Many thanks for this great tool! I just downloaded the asset and getting started.
    If anyone could help, I have a quick question on constraining the rotation on axis. I would like to move along the path but lock the rotation of the x-axis to 0. I'm still testing it but can anyone help ?

    ------------------
    Update / Fix
    Ok, that was a simple one :
    Code (CSharp):
    1. if (pathCreator != null)
    2.         {
    3.             distanceTravelled += speed * Time.deltaTime;
    4.             transform.position = pathCreator.path.GetPointAtDistance(distanceTravelled, endOfPathInstruction);
    5.             transform.rotation = pathCreator.path.GetRotationAtDistance(distanceTravelled, endOfPathInstruction);
    6.             transform.rotation = Quaternion.Euler(0, transform.eulerAngles.y, transform.eulerAngles.z); // Lock X-Axis
    7.         }
     
    Last edited: Jan 22, 2022
    G-RexStudio likes this.
  6. LibduP

    LibduP

    Joined:
    Aug 30, 2012
    Posts:
    8
    Hi everyone,

    First, I'd like to thank Sebastien for this wonderful tool, it really is helping me a lot on a small project I'm working on.

    I just encounter one major issue : I drew several paths in my scene, one not connected to the others. All of them trigger the player movement in first person view. To trigger one path, you need to click on an object in the scene (view this as a first person point-and-click prototype).
    My issue is : For a reason I don't understand, when I trigger the first path, all the paths play one after the other, as one big ride, teleporting my player from the end of one path to the start of the next one.

    I don't understand why, as I followed Sebastian documentation and created individual scripts calling each path separately, and attached to each object. As this :
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using PathCreation;
    5.  
    6. public class PathSdT : MonoBehaviour
    7. {
    8.     public GameObject player;
    9.     public PathCreator cameraPath;
    10.     public EndOfPathInstruction endBehavior;
    11.     public float speed = 1;
    12.     float distanceTravelled;
    13.  
    14.     void Start()
    15.     {
    16.        player.transform.position = cameraPath.path.GetPoint(0);
    17.     }
    18.  
    19.  
    20.     void Update()
    21.     {
    22.         distanceTravelled += speed * Time.deltaTime;
    23.         player.transform.position = cameraPath.path.GetPointAtDistance(distanceTravelled, endBehavior);
    24.     }
    25. }
    I manually set the EndOfPathInstruction parameter in the editor to be on "Stop" and not "Loop" as by default.

    Do any of you have an idea about this ?
    Thank you very much.

    Btw : I am using Unity 2019.1.14f1.
     
    Last edited: Feb 8, 2022
  7. felipiarena

    felipiarena

    Joined:
    Sep 25, 2013
    Posts:
    4
    Not sure if anyone is still here listening, but when you create a path inside a prefab it completely crazys out and starts creating random points and ticking on and off the editor path components on playmode.

    Don't use "Paths" inside prefabs, unless the creator fixes this.
     
  8. wonderfulemir

    wonderfulemir

    Joined:
    Feb 7, 2022
    Posts:
    1
    Hello, we are doing an AR project using this plug-in and Vuforia. The project is Scalextric based (game from 90s-80s), so in this game if you are on a sharp turn and you are still accelerating (or well still pressing Go_Faster) then your car shall fly out of the track and you shall lose some time against your opponent.

    So we need to know the angle during the turn that the Bezier Path Creator does... do you know if there is an easy way to do it?

    Thanks!
     
  9. CoalesceLanguidly

    CoalesceLanguidly

    Joined:
    Dec 21, 2021
    Posts:
    5

    ===============================================================
    Thank you Starfoxy. This is perfect. When I did your fix I made a new version of GetRotation and named it GetRotation2D and applied your fix (Vector3.forward as first parameter) in this.

    Did the same thing to GetRotationAtDistance to have a GetRotationAtDistance2D function which calls GetRotation2D.

    That way I can edit the path follower script to use the 2d function without affecting underlying vertex code for 3d.

    Not that it probably matters because my project is 2d anyway. I was trying to be safe, but I guess it will only be a factor if using 2d and 3d paths in same project, unless vector3.forward works with 3d paths too?

    Anyway, thank you. this is the solution I was looking for.

    And thank you to Sebastian for this fantastic and elegant path creation tool.

    All the best
     
    Last edited: May 24, 2022
  10. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    173
    Glad I could help @CoalesceLanguidly ! I guess we could dig into this further and add a checkbox to the inspector options for 2D vs 3D or have you done that?
     
  11. LTI-Carlos

    LTI-Carlos

    Joined:
    Dec 19, 2019
    Posts:
    1
    Had the same issue and it turned out to be some gizmo display setting (never figured out exactly which). What finally worked was resetting the whole Unity window layout to reset all display settings.

    Windows > Layouts > Default
     
    idkwtw223 likes this.
  12. JakobESG

    JakobESG

    Joined:
    Nov 8, 2021
    Posts:
    1
    Aye hello buddy, did you find any solution for your problem?

    I'm currently trying to implement a minimum angle. Since every vehicle has a certain turning circle which cannot be fallen below. For that its necessary to have controll over the Anchor respectively control Points. Iam still newer to Unity so just understanding all of his code is over my level.

    Best wishes
    Jakob!
     
  13. BIG_PIG123

    BIG_PIG123

    Joined:
    Mar 31, 2021
    Posts:
    1
    Did you figure it out
     
  14. spikezart

    spikezart

    Joined:
    Oct 28, 2021
    Posts:
    69
    Running 2020.3.31f1 but if I add the PathCreator to an empty object it moves on its own accord in edit mode when the component is open in the inspector.

    Some of the example scenes don't work for me also.

    I have AStar Pathfinder in the same project but all components are greyed out so Im not sure if this is an issue for me or something wider.


    Anyone experience this?
     
  15. hsklunity

    hsklunity

    Joined:
    Jun 9, 2022
    Posts:
    13
    2021.3.4f1

    I created a own path via code from the Doc:
    VertexPath GeneratePath(Vector2[] points, bool closedPath)
    {
    // Create a closed, 2D bezier path from the supplied points array

    // These points are treated as anchors, which the path will pass through

    // The control points for the path will be generated automatically
    BezierPath bezierPath = new BezierPath(points, closedPath, PathSpace.xy);
    // Then create a vertex path from the bezier path, to be used for movement etc
    return new VertexPath(bezierPath);
    }

    One problem is, that there is no VertexPath constructor that only takes a BezierPath as parameter. So I just used the bezier path (pathCreator.bezierPath = bezierPath; ).

    The other problem I have is that the path I created using my own waypoints is dislocated, meaning the shape of the path is correct but the position is not. I already checked that I'm not using the relative location of the waypoint objects but the absolute.

    Has anybody have had the same/similar issues or can help me solve them?



    Edit: If I add anchor points the curve in the curve editor. The new anchor point is created super far away and I have problems bringing it near, since I have to manually got to it in the scene view and move it via mouse or position coordinates. Any suggestions for an easier workflow?

    Edit 2: I was able to fix my problem with the dislocation of the path based on own waypoints.
     
    Last edited: Dec 12, 2022
  16. MeteTurkay

    MeteTurkay

    Joined:
    Nov 10, 2022
    Posts:
    10
    Hi, can we set start position of follower (which is point 0 on path i guess)?
     
  17. keremikzz

    keremikzz

    Joined:
    Oct 30, 2021
    Posts:
    2
    Does anyone know the solution?
    When i try the sample scene it works but when i add an empty object and try to add the path creation component i see nothing and get these errors.
     

    Attached Files:

  18. thekrocker

    thekrocker

    Joined:
    Feb 4, 2021
    Posts:
    4
    How can we change existing points in the Path Creator? I tried to use SetPoint & MovePoint, but doesnt seem to change
     
  19. CJSteamer

    CJSteamer

    Joined:
    Jun 21, 2023
    Posts:
    1
    Hi, total noob here. I've played with example scenes and paths and etc. contained in Path Creator, and all works fine.

    But in creating a scene and setting up a new Bezier curve from scratch, I'm not able to get anything to work. Following the manual, I create a GameObject, and attach the Path Creator script to it. The following error occurs immediately:

    NullReferenceException: Object reference not set to an instance of an object
    PathCreation.BezierPath.GetPoint (System.Int32 i) (at Assets/PathCreator/Core/Runtime/Objects/BezierPath.cs:131)
    PathCreation.BezierPath.get_Item (System.Int32 i) (at Assets/PathCreator/Core/Runtime/Objects/BezierPath.cs:125)
    PathCreation.Utility.VertexPathUtility.SplitBezierPathByAngleError (PathCreation.BezierPath bezierPath, System.Single maxAngleError, System.Single minVertexDst, System.Single accuracy) (at Assets/PathCreator/Core/Runtime/Utility/VertexPathUtility.cs:13)
    PathCreation.VertexPath..ctor (PathCreation.BezierPath bezierPath, UnityEngine.Transform transform, System.Single maxAngleError, System.Single minVertexDst) (at Assets/PathCreator/Core/Runtime/Objects/VertexPath.cs:49)
    PathCreation.PathCreatorData.GetVertexPath (UnityEngine.Transform transform) (at Assets/PathCreator/Core/Runtime/Objects/PathCreatorData.cs:103)
    PathCreation.PathCreator.get_path () (at Assets/PathCreator/Core/Runtime/Objects/PathCreator.cs:25)
    PathCreation.PathCreator.OnDrawGizmos () (at Assets/PathCreator/Core/Runtime/Objects/PathCreator.cs:82)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)​

    The initial curve isn't being created like it should. And it seems the "getpoint" method is causing this error because there isn't a set of points to work with.

    The sample scenes in the Path Creator package and their curves & motion work fine. It's just that I can't begin from scratch.

    I'm using Unity 2022.3.2f1.

    Any clues? Probably something obvious, but not to me...
     
    AquariuZ and stevekrile like this.