Skip to main content

Record Animation Segments

While the Coaster Tutorial and the default template provides a quick an easy way to get your ride setup and running, it has it's limitations. Not all coasters will be single circuit, one lap rides with a stop in the station. Sometimes you want to make it move non-linearly by rolling back or move through a track switch.

This tutorial will teach you how to best use the KeyframeRecorder, TriggerRecorder, and AnimationRecorder in order to generate more complex animations.

Goal

  • Learn how to manipulate KeyframeRecorder, TriggerRecorder, and AnimationRecorder to create animations.

Requirements

Overview of Creating Animations

The two building blocks of an Animation (for RTRF) are Keyframes and TriggerInfo. The classes that hold these are KeyframeRecorder and TriggerRecorder, respectively.

If you have taken a Computer Science data structures class or have experience in other programming languages, you should think of them like wrappers around arrays (see JavaScript Array).

In KeyframeRecorder order position matters since each keyframe needs to be played sequentially. Thus it's methods emphasize this to maintain order. push and append will both add their respective data to the end of the KeyframeRecorder while appendToBeginning will add to the start. (Yes these names were taken from the JavaScript Array implementation)

TriggerRecorder, on the other hand, while it uses an array structure internally, order does not matter as much. The names add and combine do not specify where in the recorder it will be added. This is because, when exporting, triggers will be re-ordered based on time position.

Author's Note

TriggerRecorder's methods will change as will make it easier to remove triggers if their index can be obtained.

AnimationRecorder is a helper class useful in helping create and export animations. It handles exporting for you. More on this in the section below.

KeyframeRecorder

First, we will review KeyframeRecorder and a few important methods. If you are coming from the Coaster Tutorial, then KeyframeRecorder should still feel very foreign to you as the template did most of the work.

:push() adds a Keyframe to the end KeyframeRecorder. :append() clones and adds the Keyframes from one KeyframeRecorder to the end of itself.

  • push allows you to manually add individual keyframes to your KeyframeRecorder

    • Importance of adding startKeyframe
      • getLast and getLastPosition methods
  • append is important because

    • simulations return a KeyframeRecorder
  • Recording segments

  • Getting data from last segment

KeyframeRecorder

  • Some review?

    • KeyframeRecorder
      • Holds keyframes
    • What do the simulator modules do?
      • Simulate some thing and output a KeyframeRecorder
  • KeyframeRecorder:push() adds a Keyframe to a KeyframeRecorder.

  • KeyframeRecorder:append() adds the keyframes of another KeyframeRecorder to a KeyframeRecorder.

    • Basically it's like combining two tables.
  • Pattern for recording simulation segments is to take the KeyframeRecorder returned by the simulation

  • Pattern for changing track, etc.

AnimationRecorder

  • AnimationRecorder

  • Allows you to keep scope separate for all the segments.

    • Why is this good?
      • Reuse variable names
        • Naming is hard!
      • Make sure we are using the correct values and overwrite some other ones
      • Organization
      • Overall, reduces the amount of things we need to keep track of.
  • recordSegment()

    • Takes a function with 4 arguments
      • keyframeRecorder
      • triggerRecorder
      • mainKeyframeRecorder
      • mainTriggerRecorder
  • Pattern is usually to have each segment handle for a given start and end position of a ride.

    • Examples:
      • Station to Station
      • Station to Pre Launch Hold and Pre Launch Hold to Station
      • Drop Track, Turntable, Elevator Lift, etc. segment
  • When would you want to use :recordAndExportSegment()?

    • Recording separate animations for drop tracks, elevator lifts, etc.
    • These are objects that move with the train.
    • We want to be able to sync these with the train, thus we want to clone the data and just change the track.
    • We will explain more in their specific tutorials.
  • show an example how you would record these animations

Full Code