Search Unity

BGCurve (free Bezier Spline Editor) support thread

Discussion in 'Assets and Asset Store' started by BansheeGz, Feb 18, 2017.

  1. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello, there is no out-of-the-box component for this, sorry
     
    whitesilverrr likes this.
  2. ovondoom

    ovondoom

    Joined:
    Oct 30, 2019
    Posts:
    1
    Hello, I'm trying to access a custom field, and seem only able to do so through the points, rather than the curve, and this is causing some issues in actually using the field in my code as it changes, as my object moves along the curve. I'm using the TRS component to translate an object, but I'd also like to use a custom field (float) on the same curve, and use the value as it's updated, so how do I do this? Can I get the value as it changes, the same way I can get the "DistanceRatio" as it does? Even if the custom fields can only be accessed through the points, is there any way to know exactly which point my object has just passed, or arch between points it's on, I suppose...?

    I hope I've explained this clearly enough. Monitoring/using "DistanceRatio" in an Update function has been incredibly useful so far, and I'd like to know how to extend that usefulness with the custom fields.
     
  3. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello,

    1) I'm not sure if I understood you correctly, I think, there is no sense in adding custom fields for a curve itself, cause you can create your own C# script, attach it to the curve's GameObject and consider all its fields as custom fields for the curve. For example, in the script below you can consider Test.myField to be a "custom field" for the curve.

    2) To calculate arch (section) you can use BGCcCursor.CalculateSectionIndex method

    3) To find a moment a cursor crosses some point, you can calculate section every frame, and once section changes you can assume cursor crossed some point

    Here is an example
    Code (CSharp):
    1. using BansheeGz.BGSpline.Components;
    2. using UnityEngine;
    3.  
    4. [RequireComponent(typeof(BGCcCursor))]
    5. public class Test : MonoBehaviour
    6. {
    7.     // consider myField as "custom field" of the curve
    8.     public float myField;
    9.  
    10.  
    11.     private BGCcCursor cursor;
    12.     private int oldSection;
    13.  
    14.     void Start ()
    15.     {
    16.         cursor = GetComponent<BGCcCursor>();
    17.         oldSection = cursor.CalculateSectionIndex();
    18.     }
    19.  
    20.     private void Update()
    21.     {
    22.         var section = cursor.CalculateSectionIndex();
    23.         if (oldSection != section)
    24.         {
    25.             //cursor just passed some point
    26.  
    27.             oldSection = section;
    28.         }
    29.     }
    30. }
    31.  
     
  4. UA_AV

    UA_AV

    Joined:
    Apr 18, 2017
    Posts:
    14
    Hello there, and thanks for making this useful free asset!

    I have a query: How is it possible to call/invoke a certain UnityEvent once the BG Curve's Cursor has reached a certain Point?

    Thank you very much!
     
  5. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello, thank you for your support!
    "CursorChangeLinear" component supports both C# (BGCcCursorChangeLinear.PointReached) and Unity/persistent (
    BGCcCursorChangeLinear.pointReachedEvent) events, which are fired when point is passed.
    You will need to use Cursor+CursorChangeLinear+TranslateObjectByCursor components, cause TRS component does not support events.

    I've attached a working example, which uses Unity events (run Assets\BansheeGzSupport\support.unity scene).
    Test.PointPassed method is called.
    I hope this will help.
     

    Attached Files:

  6. UA_AV

    UA_AV

    Joined:
    Apr 18, 2017
    Posts:
    14
    Thank you for your response!

    However, after adding the Cursor Change Linear component and setting the value of its Speed to the same value of TRS's Speed, I have observed that the Object To Manipulate moves faster than before I attached the said component.

    upload_2019-11-27_9-4-6.png

    Is it possible to use the value of Speed of the TRS component for the Object To Manipulate to move and rotate accordingly?

    Thank you again!
     
  7. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    @UA_AV

    1) You can use RotateByCursor component to rotate an object, no need to use TRS component https://www.bansheegz.com/BGCurve/Cc/BGCcCursorObjectRotate/
    TRS component is meant to be a simplified alternative to Cursor+ChangeLinear+TranslateByCursor+RotateByCursor+ScaleByCursor set of components, it's not meant to be used with these components

    2) Please, remove TRS component before adding CursorChangeLinear component or if you want to use TRS component along with Cursor+ChangeLinear+Translate by some reason, add cursor component first and then add ChangeLinear+Translate using "plus" icon on cursor component as shown on the picture.
    On your screenshot, CursorChangeLinear uses TRS component as its cursor, but it needs to use Cursor component instead. I guess it's a bug we allow to attach CursorChangeLinear to TRS component, it's a side effect of TRS component being extended from Cursor component





    3) If you want to move/rotate/scale several objects with the same cursor, you can use multiple TranslateByCursor/RotateByCursor/ScaleByCursor components, attached to the same cursor
     
  8. UA_AV

    UA_AV

    Joined:
    Apr 18, 2017
    Posts:
    14
    Great, I understand now. Thank you for your help!


    I have another query:

    I have a Cube, BGCurve Object A and BGCurve Object B. Both BGCurve Objects have almost the same points.

    (BGCurve Object A)
    upload_2019-11-29_15-17-20.png

    (BGCurve Object B)
    upload_2019-11-29_15-17-49.png

    Initially, the Cube's position and rotation are manipulated by BGCurve Object A.

    At some point in time, BGCurve Object A gets disabled, then BGCurve Object B gets enabled. The Cube is now where the BGCurve Objects intersect. Furthermore, BGCurve Object B manipulates the Cube's position and rotation.

    How do I set the Distance or Distance Ratio field from the Cursor component of BGCurve Object B based on Cube's position before BGCurve Object A gets disabled?
     
  9. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Does your second curve start at exactly the same position, where the first curve ends and you only need to switch the curves when the object reaches the end of the first curve and continue moving the object along the second curve?

    Or you need to implement smooth transition between two curves based on the shortest path between these curves at some arbitrary position?
     
  10. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    BansheeGz likes this.
  11. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Kamyker likes this.
  12. UA_AV

    UA_AV

    Joined:
    Apr 18, 2017
    Posts:
    14
    Here is a quick illustration of my enquiry:
    upload_2019-12-4_9-10-15.png

    To recap what I typed earlier, I have two BG Curve objects and a Cube. Initially, BG Curve Object 1 manipulates the movement of the Cube. When the Cube reaches the point (marked by the maroon circle), it is BG Curve Object 2's turn to control the Cube. Also, the Cube starts at the same point (marked by the maroon circle).
     
  13. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    @UA_AV

    Unfortunately, our asset does not support such functionality out-of-the-box.
    I've attached an example, which shows how this could be done, but please, keep in mind:
    1) I can not guarantee it will work properly in all possible scenarios. Thorough testing should be performed to ensure it works correctly
    2) Maybe some other spline assets support such use-case (I mean spline graph + moving object by some path inside this graph), I do not know.

    Here is the description of how the attached example works:
    1) Run BansheeGzSupport\support.unity scene.
    2) The scene contains 3 curves and CurveGraphManager, which holds the list of splines and list of transitions
    3) Each transition has the following information: 2 indexes of the curves (from->to), 2 indexes of points (from->to) and speed
    4) CurveGraphManager creates and removes components, which are required for moving/rotating an object dynamically, at runtime.
    5) Also, it attaches an event listener to track down "Point Reached" events. Once some point is reached, it checks the list of transitions to find a transition, which matches the current curve and current point. If such transition is found, CurveGraphManager switches the curves by removing old components and creating new ones.
    6) This implementation ignores the moving direction. I mean, when point #1 is crossed, there are 2 possible directions- the object can be moving forward (from section 0->1) or backwards (from section 1->0). If this direction should be taken into account, you will need to add a bool field (or some enum field) to transition class (to define the direction) and also calculate current section every frame to keep track of the current section (curve.GetComponent<BGCcCursor>().CalculateSectionIndex())
    7) See BansheeGzSupport\CurveGraphManager.cs for more details about how this example works.

    I hope it will help.
     

    Attached Files:

  14. Daniel4

    Daniel4

    Joined:
    Sep 19, 2014
    Posts:
    13
    Hi, I'm trying to figure out the best way to only show x amount of the line renderer before and after a specific point. I am moving a character along the line by finding the closest point to the player, checking one step ahead and back of the player and then move towards the point currently being looked at. So the line renderer would need to render from the point the player is on to x distance ahead and back. Any ideas how this would be most easily accomplished?

    Thanks in advance I really love the asset.
     
  15. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hi,

    1) We modified BGCurve package to add Points property to BGCcSplitterPolyline component ( https://www.bansheegz.com/BGCurve/Cc/BGCcSplitterPolyline/ ), which returns information about all points positions, distances and tangents, which could be helpful in your case. (I attached modified package BGCurve1.2.7Latest.unitypackage) UPD: code was submitted to Asset Store

    2) I attached example implementation, which creates a list of positions for LineRenderer, depending on some distance from the object (BGCurveCustomLineRendererExample.unitypackage), which uses newly added Points property.
    Run BansheeGzSupport\support.unity scene
    See BansheeGzSupport\LineRendererManager.cs for implementation details

    The final result on the image below
    I hope it will help

     

    Attached Files:

    Last edited: Feb 5, 2020
  16. Daniel4

    Daniel4

    Joined:
    Sep 19, 2014
    Posts:
    13
    Hi,

    Thanks man. You just saved me a huge ton of time. I had a system I made before to work with a spline I made myself which wasn't nearly as good. Trying to change or adapt it would have taken ages. As far as I can tell just changing update to draw and add a clear made me able to call it from the script controlling my splines.

    Using your asset has proven to be much better than trying to create something similar myself.

    Thanks a lot
     
    BansheeGz likes this.
  17. rfernandez_unity361

    rfernandez_unity361

    Joined:
    Apr 7, 2020
    Posts:
    1
    Hello!

    Thanks for all the work you've put into this asset, it's been really helpful in the recent projects I've been working on.
    I've run into a bit of a problem with it, I'm using BG Curve to generate a race course and I have a Mesh Collider attached to it so that the players and AI can run on it. My issue is that I have the race courses as prefabs and when I instantiate them into the scene, the Mesh Collider has no mesh assigned to it.

    I tried assigning the mesh from the Mesh Filter to the Mesh Collider, but it did nothing. I'm assuming it's because the mesh generated by BG Curve is instantiated and only exists in memory?
     
  18. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello!

    Could you, please, elaborate on which component(s) do you use to generate a mesh (race course)?
    Do you use Sweep2D component ( https://www.bansheegz.com/BGCurve/Cc/BGCcSweep2D/ ) ?

    1) A procedural mesh, generated by Sweep2D component, is persistent.
    It's not generated at runtime, it's instantiated from a serialized mesh.
    Mesh does not have a corresponding Unity asset, but it's stored (serialized) inside the scene asset.


    2) If you have a MeshFilter component on your GameObject and you add a MeshCollider component to the same GameObject, it should automatically reuse the same mesh a MeshFilter component has.

    I attached an example scene to this post (SampleScene.txt)
    It's a Unity scene, serialized in text (YAML) format with Unity 2019.3.
    The scene has:
    1) BGCurve+Sweep2D component to generate a mesh
    2) MeshCollider component is added to the same GameObject
    3) A sphere with rigidbody is used to make sure colliders work properly

    You can run it if you change the file extension to unity (e.g. file name should be SampleScene.unity ), copy it to your project and run it inside Unity Editor.
    If you open SampleScene.txt in a text editor and search for 49317220 inside, you will find a serialized generated mesh.
    You can also make sure the same mesh is referenced from both MeshFilter and MeshCollider components
     

    Attached Files:

  19. cdibbs

    cdibbs

    Joined:
    May 3, 2019
    Posts:
    17
    Hello!

    What's the best way to use this with a skeleton? Specifically, when the skeleton's joint positions update, I want the BgCurve + Cc Line Renderer to update as well. I had hoped passing in the joint transform.position objects to new BGCurvePoint(...) would cause this automatically, but that doesn't seem to be the case.

    Thanks!
     
  20. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello!
    try the following steps:
    1) Toggle "Transform->Show in points menu" on under "Fields" tab
    2) Assign your transforms to curve's points using the "Transform" field under "Points" tab

    I've attached screenshots and example package to this message



     

    Attached Files:

  21. cdibbs

    cdibbs

    Joined:
    May 3, 2019
    Posts:
    17
    Thanks for the quick reply. I was thinking of doing this in a script. Can the same thing be done programmatically?
     
  22. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    All the features, available in Editor, should be doable programmatically
    To assign a transform to a point you can use point's "PointTransform" property.
    I've attached an example, which generates this curve from scratch

     

    Attached Files:

  23. cdibbs

    cdibbs

    Joined:
    May 3, 2019
    Posts:
    17
    Just what I was looking for. Thanks again!
     
  24. jean-orpheo

    jean-orpheo

    Joined:
    Oct 4, 2019
    Posts:
    1
    Hi,
    Your "infinite 3D spline" example is running well on my platform, but whenever I try to do the same I have a glitch:
    When the 2nd section is reached, the cursor moves well but the object is "sent back" to the first point during one frame. As if it would respect the distance reduction but not the point removal...?
    However, as in your code, in the update function I reduce the distance, remove the first point and add another one.
    Would you know where this glitch comes from?
     
  25. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hi,
    Probably forcing math component to recalculate immediately after the changes should fix the issue
    Please, try the updated script (InfiniteSpline3D.cs)
     

    Attached Files:

  26. coolasy_unity

    coolasy_unity

    Joined:
    Oct 16, 2018
    Posts:
    2
    Hi, similarly to how the tangent vector is calculated at a distance, is there any way to retrieve the normal vector?
     
  27. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hi,
    Do you mean a normal line for a point on 2D spline, correct?
    It can be calculated as a cross-product (Vector3.Cross) of tangent and "up" vector or rotating a tangent 90 or -90 degrees around "up" axis
    For example, if a spline lays on XY plane, the "up" vector is Vector3.up (0,1,0)

    For 3D spline, you need a replacement for "up" vector, cause there are multiple lines, which are perpendicular to a tangent
     
  28. coolasy_unity

    coolasy_unity

    Joined:
    Oct 16, 2018
    Posts:
    2
    I meant for a 3D spline. I was not sure what could be used for the binormal to calculate the normal with the cross product. Or if there was some feature to calculate the normal vector based on the tangent.
     
    Last edited: Oct 30, 2020
  29. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    No, sorry, there is no such method currently
    We were not even aware that it's possible to calculate this normal vector without any additional information
     
  30. indolence

    indolence

    Joined:
    Oct 2, 2013
    Posts:
    7
    After installing both BGCurve and BGCollider, I'm now getting this warning:
    Assets\BansheeGz\BGCollider\Scripts\Collider\BGCcColliderMeshAbstract.cs(71,25): warning CS0693: Type parameter 'T' has the same name as the type parameter from outer type 'BGCcColliderMeshAbstract<T>'

    It doesn't seem to be causing any problems that I can see, but it does make me a little nervous and I try to keep my console warning-free. Is this a known issue or something that can be easily resolved?
     
  31. nogebatorr

    nogebatorr

    Joined:
    Apr 16, 2016
    Posts:
    14
    Hi, BansheeGz
    Today I've downloaded your component and must say: "It's a great job guys!"
    Everything is made with love and care.
    But looks like I found a bug when trying to load previously saved settings.

    Try this STR:
    1. Create a curve with a few points and Bezier control type.
    2. Clear property "Show Handles" for "#2. Controls" section in Fields tab
    3. Save settings
    4. Load it from the same file
    5. Try to change "Show Handles" checkbox - you will see it makes no effect for handles visualization
    6. Functionality will be restored when you deselect the current spline and select it again.

    The same problems could be found with most of the properties on the Feilds tab.
    I guess you do not refresh well reference to loaded settings somewhere in the editor so it works with the previous object and is not affected in BGCurveEditorPoint.OnSceneGUI method
     
  32. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello!
    Thank you for reporting the issue

    Please, replace BGCcColliderMeshAbstract.Get method with the following code:
    Code (CSharp):
    1.         protected TC Get<TC>() where TC : Component
    2.         {
    3.             var component = GetComponent<TC>();
    4.             if (component == null) component = gameObject.AddComponent<TC>();
    5.             return component;
    6.         }
    or wrte to our support email, so we could send you a package with a fix
    Thank you
     
  33. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hi, thank you for reporting the issue!
    Please, upgrade BGCurve (I attached the package)
     

    Attached Files:

  34. nogebatorr

    nogebatorr

    Joined:
    Apr 16, 2016
    Posts:
    14
    Hi, BansheeGz
    Thank you for so fast response!
    My issue is fixed now.
    Magnifique!
     
  35. indolence

    indolence

    Joined:
    Oct 2, 2013
    Posts:
    7
    Thanks for the quick fix! Appreciated!
     
  36. FotusCN

    FotusCN

    Joined:
    Oct 28, 2016
    Posts:
    5
    Hi @BansheeGz , I am using "Splitter Polyline [Component]". When i create a Love(Heart) Curve, the parts on the top is very dense, But the bottom is very sparse, Is there any way to make the parts uniform and the distances are roughly equal. BGCurve is great, thank you.
     
  37. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello,
    There are 2 methods to calculate points' positions:
    1) Basic
    2) Adaptive
    You can switch between them using the Math component's "Math Type" parameter
    1) If the type is basic, points positions are (almost) uniformly distributed along the spline
    2) If the type is adaptive, the number of points depends on the curve's steepness.
    The less curve's steepness, the fewer points are needed
     
  38. Tiollo

    Tiollo

    Joined:
    Mar 14, 2015
    Posts:
    23
    Hi there! I have a little issue when moving the cursor on the path via code.

    For example, I'm trying to do this, so that the cursor moves depending on an animation (which is triggered by an input from the player):
    Code (CSharp):
    1.  
    2.             float distanceRatio = Mathf.Lerp(
    3.                 0, 1, animationTimer / animationDuration
    4.             );
    5.             distanceRatio = Mathf.Clamp01(distanceRatio);
    6.             bezierPathCursor.DistanceRatio = distanceRatio;
    7.  
    But there a few issues.
    If I set the speed of the cursor as 0, the code above it won't work at all and the cursor won't move.
    If I set the speed to any other value (for example I tried to use a very low number and then set it to 0 when it should not move), the distanceRatio is shown as correct in the inspector, but from the scene view is always different somehow.

    I'm also trying other options without using linear interpolations and the distance ratio depends on another generic player's input between 0 and 1. But same issue :(

    Do you have any suggestion to solve this problem?

    Thanks a lot in advance, BGCurve is my favourite spline editor out there :)
     
    Last edited: Sep 9, 2021
  39. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hi!
    Since you do not need speed, cause you are calculating the distance directly, you could create your own component for moving an object
    Delete the component, which moves the object, and add your own component.

    Here is a working example of such a component (Replace the marked blocks of code with your own code):
    Code (CSharp):
    1. using BansheeGz.BGSpline.Components;
    2. using UnityEngine;
    3.  
    4. [RequireComponent(typeof(BGCcMath))]
    5. public class MoveAlongSpline : MonoBehaviour
    6. {
    7.     public Transform objectToMove;
    8.  
    9.     private BGCcMath math;
    10.  
    11.     //replace this code
    12.     private float animationTimer;
    13.     private float animationDuration;
    14.  
    15.     void Start()
    16.     {
    17.         math = GetComponent<BGCcMath>();
    18.        
    19.         //replace this code
    20.         animationTimer = 0;
    21.         animationDuration = 10;
    22.     }
    23.  
    24.     void Update()
    25.     {
    26.         //replace this code
    27.         animationTimer += Time.deltaTime;
    28.        
    29.         float distanceRatio = Mathf.Lerp(
    30.             0, 1, animationTimer / animationDuration
    31.         );
    32.         distanceRatio = Mathf.Clamp01(distanceRatio);
    33.  
    34.         objectToMove.position = math.CalcPositionByDistanceRatio(distanceRatio);
    35.     }
    36. }
     
  40. Tiollo

    Tiollo

    Joined:
    Mar 14, 2015
    Posts:
    23
    That's smart, don't know why I didn't think that I could move it also without using the TRS component :D

    Thanks a lot again!
     
    BansheeGz likes this.
  41. lavnishgamer

    lavnishgamer

    Joined:
    Sep 18, 2021
    Posts:
    1
    Hey, How do I add a transform to the curve through another script? I would be instanting a car with a script, which will access it's position ratio using as you said
    Code (CSharp):
    1. GetComponent<BGCcCursor>().DistanceRatio
    But i don't know how to add the object to the curve.
     
  42. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hello,
    You can add BGCcTrs component in runtime for each car and then assign car's transform to the added BGCcTrs component using ObjectToManipulate property
    Code (CSharp):
    1.         //add trs component
    2.         var trs = math.gameObject.AddComponent<BGCcTrs>();
    3.         //create an object
    4.         var obj = Instantiate(Prefab);
    5.         //assign object to trs component
    6.         trs.ObjectToManipulate = obj.transform;
    Full code:
    Code (CSharp):
    1. using BansheeGz.BGSpline.Components;
    2. using UnityEngine;
    3.  
    4. [RequireComponent(typeof(BGCcMath))]
    5. public class Spawner : MonoBehaviour
    6. {
    7.     public GameObject Prefab;
    8.  
    9.     public int numberOfObjectsToSpawn = 5;
    10.  
    11.     private BGCcMath math;
    12.  
    13.     void Start()
    14.     {
    15.         math = GetComponent<BGCcMath>();
    16.         for (var i = 0; i < numberOfObjectsToSpawn; i++) Spawn();
    17.     }
    18.  
    19.     private void Spawn()
    20.     {
    21.         //add trs component
    22.         var trs = math.gameObject.AddComponent<BGCcTrs>();
    23.         //create an object
    24.         var obj = Instantiate(Prefab);
    25.         //assign object to trs component
    26.         trs.ObjectToManipulate = obj.transform;
    27.  
    28.         trs.DistanceRatio = Random.Range(0f, 1);
    29.         trs.Speed = Random.Range(-10f, 10);
    30.     }
    31. }
    I attached a package with example scene
     

    Attached Files:

    Last edited: Sep 20, 2021
  43. zdgra

    zdgra

    Joined:
    Feb 27, 2021
    Posts:
    9
    Hi BansheeGz, thank you so much for releasing this wonderful tool. It's a huge help, and I'm very grateful that you've made it free. Thank you so, so much.

    I need some help and I thought I'd come here to ask. First, let me provide some background. I'm on a game project where the premise is dodgeball in space, and one of our mechanics is that the ball will be gravity-assisted by each planet, where the planet's gravity influences the ball to curve around it once the ball is in the range of its gravity (you can see many videos of it on YouTube). Right now, our game is a basic prototype where the player is tasked with throwing the ball into a goal and using the planets' gravity to do so. Now, I've found no good way to implement the gravity, and yesterday it dawned on me to try using splines to simulate this effect.

    I currently have a basic spline tracing the path that I see the ball going around a planet, as you can see in the screenshot below.

    spline ex.png

    The ball would enter point #1 and exit out point #0.

    Now, what I'm wondering is whether I can have the ball enter this spline and trace its path, which is what I want to do. I know that one of the things you can do with your spline tool is have an object trace the path of a spline when it's already on the spline path. However, what I don't know is whether I can have my ball enter the spline from outside of the spline and then follow its path. Please let me know if your spline tool supports this, and how I can do have my ball do this if it can.

    Now, let's say this is possible. Would there be some way to have the ball enter the spline even if it doesn't enter it on the exact first point of the spline (in my screenshot, point #1)? Specifically, I want to know if I can create a radius from the first point that, if touched by the ball, would make the ball enter the spline. For instance, let's say this was possible, and the first point was (0, 0, 0) and my radius was 5. Then if the ball is thrown and the center of the ball hits (0, 0, 5), it would enter the spline and trace its path. I'm wondering if there's a way for me to do that, assuming that what I asked about in the last paragraph is possible.

    I'd love to hear back from you soon! Thank you so much :)
     
  44. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    Hi!

    1) Did you try to use Unity physics (rigidbody) for this task?
    This post describes how to simulate local gravity : https://answers.unity.com/questions/1543639/how-to-set-individual-rigidbody-gravity-solved.html
    It seems like it's an easier/better solution than using splines

    2) Maybe you will be able to create a spline dynamically, in runtime, based on the object trajectory, speed and gravity force. To be honest, I feel like using physics is a better option
     
  45. zdgra

    zdgra

    Joined:
    Feb 27, 2021
    Posts:
    9
    I have, to be honest. I have tried quite a few gravity-based/physics-based solutions, but I have not been successful in doing so.
     
  46. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    And what was the problem?

    Sorry, we do not know any easy way to implement it
    You could try to create a spline in runtime- in this case, you will not have to enter the spline, cause the spline will be a continuation of the object's path
     
  47. zdgra

    zdgra

    Joined:
    Feb 27, 2021
    Posts:
    9
    Oh no, it's no worries - I did not come here wanting to get a solution for how to implement it. I just wanted to ask if those things I mentioned above are possible to implement using your tool.
     
  48. zdgra

    zdgra

    Joined:
    Feb 27, 2021
    Posts:
    9
    I can see where you're going, but see, what I had in mind was using the spline as a pathway for the ball to curve around the planet. If I had the spline be a continuation of the ball's path, then I wouldn't need it - I would just have the ball keep going in a straight direction.
     
  49. BansheeGz

    BansheeGz

    Joined:
    Dec 17, 2016
    Posts:
    370
    I was assuming the object can enter the planet's gravitational field in any position with any trajectory and speed, so you could try to adjust the spline to match the object's path/speed (as shown on the image below)
    I'm not sure if this is good advice though
     
  50. zdgra

    zdgra

    Joined:
    Feb 27, 2021
    Posts:
    9
    I seeee, interesting. I'll try it out! Thank you so much!