Vector3Curve

Show Deprecated

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

Creating a Vector3Curve

1--- Vector3Curve
2local function createVector3Curve()
3 local vectorCurve = Instance.new("Vector3Curve")
4 local curveX = vectorCurve:X() -- creates and returns a FloatCurve animating the X channel
5 local curveY = vectorCurve:Y() -- creates and returns a FloatCurve animating the Y channel
6 -- 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 animation
8
9 local key = FloatCurveKey.new(0, 1) -- creates a key at time 0 and with value 1
10 curveX:InsertKey(key)
11 curveY:InsertKey(key)
12 local key2 = FloatCurveKey.new(1, 2) -- creates a key at time 1 and with value 2
13 curveX:InsertKey(key2)
14 curveY:InsertKey(key2)
15 return vectorCurve
16end
17
18local function testVector3Curve()
19 local curve = createVector3Curve()
20
21 -- sampling the curve at a given time (returns a vector3)
22 print(curve:GetValueAtTime(0)) -- returns 1, 1, void
23 print(curve:GetValueAtTime(0.5)) -- returns 1.5, 1.5, void (result of cubic interpolation with auto tangents)
24
25 curve:X():RemoveKeyAtIndex(1)
26 curve:X():RemoveKeyAtIndex(1)
27 print(curve:X().Length) -- number of keys = 0
28 print(curve:GetValueAtTime(0.5)) -- returns void, 1.5, void
29end
30
31testVector3Curve()

Summary

Properties

Events

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.

X(): FloatCurve  

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.

Y(): FloatCurve  

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.

Z(): FloatCurve  

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.

Properties

Events

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

time: number

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.


Returns