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().
1--- Vector3Curve2local function createVector3Curve()3 local vectorCurve = Instance.new("Vector3Curve")4 local curveX = vectorCurve:X() -- creates and returns a FloatCurve animating the X channel5 local curveY = vectorCurve:Y() -- creates and returns a FloatCurve animating the Y channel6 -- Not setting the Z channel will leave the Z channel not animated.7 -- A missing curve or a curve with no keys don't participate in the animation89 local key = FloatCurveKey.new(0, 1) -- creates a key at time 0 and with value 110 curveX:InsertKey(key)11 curveY:InsertKey(key)12 local key2 = FloatCurveKey.new(1, 2) -- creates a key at time 1 and with value 213 curveX:InsertKey(key2)14 curveY:InsertKey(key2)15 return vectorCurve16end1718local function testVector3Curve()19 local curve = createVector3Curve()2021 -- sampling the curve at a given time (returns a vector3)22 print(curve:GetValueAtTime(0)) -- returns 1, 1, void23 print(curve:GetValueAtTime(0.5)) -- returns 1.5, 1.5, void (result of cubic interpolation with auto tangents)2425 curve:X():RemoveKeyAtIndex(1)26 curve:X():RemoveKeyAtIndex(1)27 print(curve:X().Length) -- number of keys = 028 print(curve:GetValueAtTime(0.5)) -- returns void, 1.5, void29end3031testVector3Curve()
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.