Unity provides standard Spline asset Getting started with Splines | Splines | 2.1.0 , use BGCurve only if some feature is missing
BGCurve is free Bezier spline editor
Asset Store: https://assetstore.unity.com/packages/tools/bg-curve-59043
Docs: BansheeGz
Github: GitHub - bansheeGz/BGCurve: Bezier spline editor for Unity game engine
Known issues
Current implementation may have some problems with Undo operation (Ctrl+z), which can result in a broken curve’s GameObject in some scenarios
4 Likes
Hi, I have created spline and now I need to launch several prefabs on it. How to do it? Docs aren’t so descriptive as I can see.
You need to attach instance of your prefabs to cursors on the spline.
To do it:
-
Select your curve. In the inspector window ensure you have BgCurve component which has 4 tabs: Points, Components, Fields and Settings.
-
Go to Components tab on BgCurve component.
-
Make sure you have Math component. If you don’t have it then you can add it using the green plus button.
-
Add Cursor component for Math component (using green plus button). Cursor allows moving along spline.
-
For the Cursor component add Translate Object By Cursor component.
-
Add your prefab’s instance as Object To Manipulate.
-
Repeat steps 4-6 if you want more objects which moves along spline.
With such setup you can now manipulate cursor’s distance to move the object attached to it. You can do it either from script, from animation or from additional Cursor’s component called Cursor Change Linear which moves the cursor automatically.
Yes, I was also confused at the beginning. Actually I’ve learned most from BGCurveDemo2 from examples directory and after getting the idea of basic concepts I used the docs as the API reference.
1 Like
I have a few spline-segments where the endpoint of one segment ist the startpoint of another spline. I want to move a object on the splines. How can i setup the objectToManipulate becomes the one of the next spline and follow the next spline? How do i access this with a script?
something like this should work
void Update()
{
BGCurve fromCurve;
BGCurve toCurve;
//assuming both curves have BGCcCursorObjectTranslate (and BGCcCursorChangeLinear) components
var fromCurveTranslate = fromCurve.GetComponent<BGCcCursorObjectTranslate>();
var toCurveTranslate = toCurve.GetComponent<BGCcCursorObjectTranslate>();
//if we reach the end point
if (fromCurveTranslate.Cursor.Math.GetDistance() - fromCurveTranslate.Cursor.Distance < TOLERANCE)
{
toCurveTranslate.ObjectToManipulate = fromCurveTranslate.ObjectToManipulate;
fromCurveTranslate.ObjectToManipulate = null;
}
}
Can’t see my Curve in Canvas? Is it works with canvas components (like scroll view)?
spline itself does not imply any restriction.
However if you try to use our BGCcLineRenderer component (which uses standard Unity’s LineRenderer) to visualize the spline under Canvas component, you may want to check this out http://answers.unity3d.com/questions/1201050/is-there-way-to-have-line-renderer-on-a-canvas.html
I have code that disable gameobject with bgcurve. After enabling, object doesn’t move. Speed is set, distance ratio is 0. I thinks that’s bug.
That was because of setting “Overflow Control”. If set “Stop” then it won’t continue. I’ve cycled it and set trigger at ratio 0.99 and it works. Maybe I could do this by another way?
I’m thinking about using it but I have a question. Can you programatically add points further along the spline such that you can have a shape with colliders growing outward over time? I’m making a bullet hell game and want to be able to have curvy lasers like these:
or the ones at 3:20 in this video
and was trying to figure out if BGCurve would be a good solution.
Yes, you can add, move, delete points at runtime. As for colliders, you will have to create them yourself.
The question- is it really worth it to use BGCurve is hard to answer.
I do not monitor splines solutions for Unity and i do not know if better tool for such task exists or not.
Also BGCurve is limited to Bezier interpolation only.
And ,I guess,the task itself can be accomplished by different methods as well.
If trajectories are static and predefined, you can simply animate the splines with Unity animation tools or draw these trajectories beforehand and then simply follow them with your lasers.
If trajectories are built at runtime with some fancy math formulas Im not sure if you can take advantage of BGCurve.
You don’t understand. The problem is in setting “Stop” that won’t let object to move again.
OverflowControl field defines how the cursor behaves when it reaches the end of the spline.
If you chose Stop-it stops and do not move anymore. The Stop field is set to true.
If you need it to move again- you can set Stop field to false and move cursor somewhere in the middle of the spline.
If you set OverflowControl to any other value different from Stop- this field would never be set to true.
Note, that you can also control the cursor behavior from script by setting Speed field of ChangeCursorLinear component (positive- move toward the end,0-stop, negative-move towards start) and you can also control the cursor position from script by setting Distance or DistanceRatio fields of Cursor component.
I hope it makes sense.
1 Like
hi i would like to know the percentage distance my object has travelled through the spline or access the “Distance Ratio” in the Cursor is there already a script to do this?
Hi, DistanceRatio is percent, divided by 100.
You can access it with
GetComponent().DistanceRatio
BGCcCrusor does not show up, i am in a new script which is basically empty and have the namespace of “bansheeGz.BGSpline.Curve” what am i missing?
You just need
csharp* *using BansheeGz.BGSpline.Components;* *
Hi. Do you know a good way to make actual spirals using BG curve. Do you have a good equations for point and control placement? I’ve playing around with it a lot and am struggling to figure it out myself.