Vector3Curve
Represents a 3D vector curve containing 3 FloatCurves, stored as 3 FloatCurve children instances. Each FloatCurve can be accessed via Vector3Curve:X(), Vector3Curve:Y(), Vector3Curve:Z() methods. The 3 axes can be sampled simultaneously via the method Vector3Curve:GetValueAtTime().
Code Samples
--- Vector3Curve
local function createVector3Curve()
local vectorCurve = Instance.new("Vector3Curve")
local curveX = vectorCurve:X() -- creates and returns a FloatCurve animating the X channel
local curveY = vectorCurve:Y() -- creates and returns a FloatCurve animating the Y channel
-- Not setting the Z channel will leave the Z channel not animated.
-- A missing curve or a curve with no keys don't participate in the animation
local key = FloatCurveKey.new(0, 1) -- creates a key at time 0 and with value 1
curveX:InsertKey(key)
curveY:InsertKey(key)
local key2 = FloatCurveKey.new(1, 2) -- creates a key at time 1 and with value 2
curveX:InsertKey(key2)
curveY:InsertKey(key2)
return vectorCurve
end
local function testVector3Curve()
local curve = createVector3Curve()
-- sampling the curve at a given time (returns a vector3)
print(curve:GetValueAtTime(0)) -- returns 1, 1, void
print(curve:GetValueAtTime(0.5)) -- returns 1.5, 1.5, void (result of cubic interpolation with auto tangents)
curve:X():RemoveKeyAtIndex(1)
curve:X():RemoveKeyAtIndex(1)
print(curve:X().Length) -- number of keys = 0
print(curve:GetValueAtTime(0.5)) -- returns void, 1.5, void
end
testVector3Curve()
Summary
Properties
Methods
Samples the 3 FloatCurves (X, Y, Z) at the time passed as argument. Returns the 3 samples as a tuple of 3 numbers. If a channel curve is missing or no key is found in the curve the channel is evaluated as nil.
Returns the FloatCurve controlling the X channel. It is the first child instance of type FloatCurve named X. If none is found an empty FloatCurve is created.
Returns the FloatCurve controlling the Y channel. It is the first child instance of type FloatCurve named Y. If none is found an empty FloatCurve is created.
Returns the FloatCurve controlling the Z channel. It is the first child instance of type FloatCurve named Z. If none is found an empty FloatCurve is created.
Events
Properties
Methods
GetValueAtTime
Samples the 3 FloatCurves (X, Y, Z) at the time passed as argument. Returns the 3 samples as a tuple of 3 numbers. If a channel curve is missing or no key is found in the curve the channel is evaluated as nil.
Parameters
Returns
Returns the FloatCurve controlling the X channel. It is the first child instance of type FloatCurve named X. If none is found an empty FloatCurve is created.
Returns
Returns the FloatCurve controlling the Y channel. It is the first child instance of type FloatCurve named Y. If none is found an empty FloatCurve is created.
Returns
Returns the FloatCurve controlling the Z channel. It is the first child instance of type FloatCurve named Z. If none is found an empty FloatCurve is created.