forked from 20tab/UnrealEnginePython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurve_generator.py
More file actions
43 lines (29 loc) · 1.18 KB
/
curve_generator.py
File metadata and controls
43 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import unreal_engine as ue
from unreal_engine.classes import CurveFloatFactory, CurveVectorFactory
from unreal_engine.structs import RichCurve, RichCurveKey
import time
factory = CurveFloatFactory()
curve = factory.factory_create_new('/Game/CustomFloatCurve' + str(int(time.time())))
keys = []
for i in range(0, 100):
keys.append(RichCurveKey(Time=i, Value=i))
# use ref() to set struct values on-the-fly
curve.FloatCurve.ref().Keys = keys
curve.post_edit_change()
ue.open_editor_for_asset(curve)
factory = CurveVectorFactory()
curve = factory.factory_create_new('/Game/CustomVectorCurve' + str(int(time.time())))
# one curve list for each axis
keys_x = []
keys_y = []
keys_z = []
for i in range(0, 100):
keys_x.append(RichCurveKey(Time=i * 0.1, Value=i * 0.1))
keys_y.append(RichCurveKey(Time=i * 0.1, Value=i * 0.1))
keys_z.append(RichCurveKey(Time=i * 0.1, Value=i * 0.1))
# FloatCurves is a native array, use property index (0=x, 1=y, 2=z)
curve.set_property('FloatCurves', RichCurve(Keys=keys_x), 0)
curve.set_property('FloatCurves', RichCurve(Keys=keys_y), 1)
curve.set_property('FloatCurves', RichCurve(Keys=keys_z), 2)
curve.post_edit_change()
ue.open_editor_for_asset(curve)