Bhristt's Bezier Curve Module (Tween support)

well the solution was just switching to spines specifically nurbs (non-uniform rational B-spline) also known just as a b-spline where i created a module for myself, I don’t plan on open sourcing it but i bet you could just search for it online and something will show up!

edit:

yeah there is a few open sourced spline modules if you just search em up.

1 Like

Sweet, I get to create lines from different points, I hope. I’m going to be trying this module for VFX work for sword slashes real soon to see if it’s even possible. Thank you for this resource, man.

1 Like

If you’re using a part then you have to make it anchored. That is probably why its doing that

1 Like

Such an awesome module, currently using for Blader’s Odyssey development.

One major issue I had with the module, however, and that I had to manually fix within the module’s code is that when you use BaseParts as a BezierPoint, the connections for it when you call CreateCFrameTween() or CreateVector3Tween() don’t clean up, even when the tween has finished and there is no need to call :UpdateLength() when the part’s position updates, causing massive lag over time if the BasePart still exists and moves around. For example, a projectile attack creates 50 projectiles that Bezier home onto a Character’s HumanoidRootPart, but when the tween has finished, the connections don’t clean up, and since the Character’s HumanoidRootPart still exists and is moving around, the UpdateLength() is still firing every single frame multiplied by the 50 Beziers that are created, whilst there is no need for the Bezier to exist at this point and everything is cleaned up.

The solution was just to loop through the Bezier’s ._connections table and Disconnect the :GetPropertyChangedConnection() connections when the .Completed event of the tween fires.

Went crazy trying to figure out why the framerate would drop to 10 after the special attack, as the last place I thought to check was the module itself.

1 Like

Oh, this is a really good point. Though your changes will fix the issue, this issue goes deeper than just the tween function. I completely forgot to add a destroy function for the Bezier curves.

So even if you create Bezier curves that aren’t used for tweening, they will continue to update based on the changed events of the parts used to create the curves. This is definitely a memory leak I need to fix. I’ll make sure to add a destroy method for the Bezier curves soon.

With the destroy method, all you’ll have to do is make sure you add a listener to the Completed event of the tween you get.

local tween = bezier:CreateCFrameTween(object, propTable, tweenInfo, relativeToLength)
tween.Completed:Connect(function()
    bezier:Destroy() -- this is the method i need to add
end)

Thanks for pointing this out! I’ll add a fix to this issue when I have time :smile:

1 Like

Heya, I love the module. One thing I want to know though, how would I go about updating the point positions. I do understand it’s “Bezier:CalculatePositionAt(t)”; however. Can you give an example of how to calculate “t” without visualizers as shown in the example?

Kind of like a part homing in on the player. (The player moves of course.)

1 Like

hey chris, is there any way I can run the Tween on the client sided and calculate the bezier curve on the server side?

2 Likes