Set up keyframes¶
Tip: scenarios and keyframes
Declare a Scenario
to help us describe changes happening to objects or the
environment. A scenario is a sequence of states defined by keyframes
, similar to a video timeline.
Examples of changes include: moving objects, gradually or suddenly changing the weather, or randomizing the presence, positions, or properties of objects.
Let’s take our speedboat from earlier and describe how its position changes over a few keyframes.
Register keyframes¶
# Track the initial position of the boat
start = boat.position
# Create a scenario for the speedboat with 10 frames
scenario = world.new_scenario(num_frames=10)
# Say what changes via keyframes
for i in range(scenario.num_frames):
scenario.set_keyframe(boat, i, position=start + Vector3(i, 0, 0)) # Move the speedboat 1m in the x-axis per keyframe
Note
Currently, keyframes do not interpolate automatically. You must define states and properties at every keyframe.