Easy BezierCurve | Create any curve path

Easy-BezierCurve | Version - 2.0.0

英文简介/English Language

What is the use of this module?
This module allows you to quickly create Bezier curves and to change the orientation of the target object to the orientation of the curve trajectory

Script Feature:

  • Creating Bezier curves easily
  • Orient the target object to a curved trajectory
  • Obtain the three-dimensional coordinates of the point P2 which makes the curvature of the curve converge to the circumference
  • More features are under development
中文简介

这个模块有什么用?
此模块可以支持您快捷地创建贝塞尔曲线,并支持将目标物体的朝向变为曲线轨迹朝向!

脚本功能:

  • 便捷地创建贝塞尔曲线
  • 使目标物体朝向为曲线轨迹
  • 获取使曲线曲率趋近于圆周率的P2点三维坐标
  • 更多功能正处于开发中

Example1: Link
Example2: Link

Example Code (With tween function)
local Bezier = require(ReplicatedStorage.Utils.BezierCurve)
local Player = game:GetService("Players").LocalPlayer
local PlayerCharacter = Player.Character
local HumanoidRootPart = PlayerCharacter:FindFirstChild("HumanoidRootPart")

--<Variables>--
local Elasped = 0
local Connection
local Start = HumanoidRootPart.Position
local End = HumanoidRootPart.Position + Vector3.new(10, 0, 0) --<Offset end point>--
local MidPoint = (Start:Lerp(End, 0.33)) + Vector3.new(0, 10, 0) --<Set the middle point offset 10 studs>--
local CurveTime = 10 --<Run duration>--
local TweenTime = Instance.new("NumberValue")
TweenTime.Parent = PlayerCharacter
TweenTime.Value = 0

game:GetService("TweenService")
	:Create(TweenTime, TweenInfo.new(CurveTime, Enum.EasingStyle.Quart), { Value = CurveTime })
	:Play()

--<Curve>--
Connection = game:GetService("RunService").Heartbeat:Connect(function(Delta)
	Elasped += Delta

	local Time = TweenTime.Value * (1 / CurveTime)
	local Curve = Bezier.QuadraticBezierCurves(Time, Start, MidPoint, End)

	if TweenTime.Value >= CurveTime then
		warn("Exceed max time")
		Connection:Disconnect()
		PlayerCharacter:PivotTo(
			CFrame.new(End)
				* CFrame.Angles(
					math.rad(HumanoidRootPart.Orientation.X),
					math.rad(HumanoidRootPart.Orientation.Y),
					math.rad(HumanoidRootPart.Orientation.Z)
				)
		)
		TweenTime:Destroy()
	else
		PlayerCharacter:PivotTo(
			CFrame.new(Curve)
				* CFrame.Angles(
					math.rad(HumanoidRootPart.Orientation.X),
					math.rad(HumanoidRootPart.Orientation.Y),
					math.rad(HumanoidRootPart.Orientation.Z)
				)
		)
	end
end)
Secret

Sry for my bad code skill, i’m actually a VFX Artist :broken_heart:
If you meet any bug, just tell me

Made By Aidaren - 究极挨打人
Credit: 老胡家的拖鞋/枫

35 Likes

Very Very useful module! Thank you

2 Likes

Thanks so much. This will benefit many people! Keep it up!

2 Likes

Thanks for the module, a really simple way to create bézier curves!!

1 Like

Can you share the place file that you showed in Example 2. Or just do a example game with copyable

1 Like

Example code seems not to work, probably because of the missing parameter at the end. For the cframe offset

2 Likes

Nice module, now i can make curved tweens!

1 Like

I think you should use Attachments instead of Parts from some performance gain. There is a tiny error in version 1.3.0 in the Get2Middle function. You forgot to return the position.

1 Like

This is not a standard instance code, only to show you how to use this module

Thank you for reminding me that this has been repaired in the V1.3.1 version

I noticed that there might be a performance issue when many projectiles are flying at once. This could be on my end. If possible, I suggest adding support for a table of instances so that many instance positions can be updated in every frame of just one event. I sort of adjusted the module to support this, but it would be better coming from the creator.

It is also pretty hard to calculate the time needed to reach the goal. It would be nice to have this addition since timing is also pretty important when syncing with animations.

1 Like

Huge thanks for your feedback, i will add add for instance feature in future and get time function.

I adjusted it again now. Parallel Lua can be used. Run the “reading/computing state” in parallel, and change the frame in serial. Also, I would replace parts with attachments since attachment is much cheaper to compute performance-wise. By doing so, I improved my performance by at least 2x. Running multiple instances was less of an issue.

That’s great! but for parallel lua, i cant turn my module to this way now, because im still bad on coding xD

Question/Help, I want to apply this to an AI Traffic/Opponent vehicle, currently I have it setup to simply avoid walls, how could I incorporate this to only return the given point of the curve


sorry i dont understand what your want, can you describe your question more details?