Vector3Curves: Need a easy explanation

I’ve read the documentation and have searched for posts and it doesn’t seem clear to me.

I heard about them from another post and they interested me about Vector3Curves (just remembered that it was a post about how Blade Ball’s system works)

Could anyone explain how they work (like how to use them)?

I know that there are FloatCurveKeys involved but other than that I don’t really understand it.

EDIT: I saw another post about Vector3Curves but once again it’s not really explained well

EDIT 2: So far no one has come forward and explained yet. Still gonna wait tho

Here’s the docs btw: Vector3Curve | Documentation - Roblox Creator Hub

3 Likes

bumping this. Im also confused on what Vector3Curves are

1 Like

yeah I’m still wondering. I don’t think many people know how they work so if anyone could explain, that’d be cool!

(I’ve seen the documentation but it’s still a bit confusing)

1 Like

Those doesn’t look to have an Icon or Name when generated, no properties that aren’t inherited from Instance, pretty much like nothing as far as you can see.
(its a vector3 with floatcurves)

1 Like

Yes I guess they don’t actually show up in the explorer. Well yeah hopefully someone does know how they work and can explain it

I used Instance.new() on the command bar to get a Vector3Curves on the explorer.

Oh nevermind then. Well I haven’t really messed with them a lot yet because I’m awaiting a reply

The documentation is still confusing…

They’re just data types typically used for the curve animation editor.

Ultimately they’re used to create splines composed of control points without having to manually do the math required for it.

local splinePoints = workspace:WaitForChild('SplinePts') -- our control points
local splineVisualization = workspace:WaitForChild('SplineVisualization')

local function updateCurve()
	local points = {}

	for _, child in splinePoints:GetChildren() do
		table.insert(points, tonumber(child.Name) :: number, child.Position :: Vector3)
	end
	
	local curve = Instance.new('Vector3Curve') -- curve that will represent our spline	
	
	local floatCurves = { -- get our FloatCurveKeys, these will be used to give our curve positional data; each axis will have its own 1-dimensional curve
		X = curve:X();
		Y = curve:Y();
		Z = curve:Z()
	} :: { [string]: FloatCurveKey }

	for key, point in points do
		for _, axis in { 'X'; 'Y'; 'Z'; } do
			local keypoint = FloatCurveKey.new(key / #points, point[axis], Enum.KeyInterpolationMode.Cubic) -- this will be a "keypoint" for which 1-dimensional curve we're working with

			floatCurves[axis]:InsertKey(keypoint)
		end
	end
	
	splineVisualization:ClearAllChildren()

	-- now we can create parts for each increment along our Vector3Curve. here we do 0.01 as our increment for 100 "samples" along the curve
	
	for i = 0, 1, 0.01 do
		local part = Instance.new('Part')

		part.Position = Vector3.new(unpack(curve:GetValueAtTime(i)))
		part.Anchored = true
		part.Size = Vector3.new(0.1, 0.1, 0.1)
		part.Material = Enum.Material.Neon
		part.Parent = splineVisualization
	end
end

for _, child in splinePoints:GetChildren() do
	child:GetPropertyChangedSignal('CFrame'):Connect(updateCurve)
end

4 Likes

Hey Cody!

I’ve made a Devforum post a little while ago, I’m wondering if this Vector3Curve could help me find the solution to it.

Here’s the post

Okay wow! I think I’m gonna be referring to this! Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.