The 6 Essential Fields

There are 6 essential fields that really define a sequence. 4 of them are attached to an effect object and the other 2 are attached to a sequence object. Once you master these 6 fields you’ll be able to define any sequence, all of the other fields are just ways to control the specifics of how the effect plays out.

The 6 fields are:

Effect.Duration
Effect.RetrieveStart
Effect.RetrieveEnd
Effect.OnUpdate
Sequence.Reference
Sequence.RetrieveSequenceStart
  1. Effect.Duration is simple enough, it’s a float. It holds the number of seconds that the sequence should take to get from the start value to the end value.
  2. Effect.RetrieveStart is an action. It receives the Reference (like all actions do) and it also receives a value that I always label “lastEndValue” (or lastEnd if I’m in a hurry.) lastEnd is the value that was returned by the last call to Effect.RetrieveEnd. Usually, if you’re running a sequence with several effects in it, you’ll want to start the current effect at the point where the last effect left off. In fact, if you leave this field as null then the start value will be set to the last effect’s end value by default.
  3. Effect.RetireveEnd receives the Reference and returns the end value (or target) of the effect.
  4. Effect.OnUpdate is the heart of the whole affair. This function receives a reference and the current computed value. This function should be as short as possible, since it will be called every frame. It’s one task is to set whichever aspect of your environment that you are performing the effect on to the value that is passed in.
  5. Sequence.Reference should be assigned to whichever object holds the data that will need to be referenced in order to do the effect. This can be any object of any type. When you define the Effect or Sequence variable you specify the type of the Reference as the first templated argument (i.e. new Effect<"Reference Type", "Variable type you are acting on">). Often the Reference can be set to type of the current script that you are using, and then you can set Sequence.Reference to “this”. When you do that your reference can access any public or private variables in the current script. If you set Reference to the this pointer a good convention is to name it “me” when it’s passed in to any of the other actions.
  6. Sequence.RetrieveSequenceStart is a little different then the Effect.RetrieveStart function. Remember that Effect.RetrieveStart receives the lastEndValue each time it is called, which begs the question “what value is supplied to the first effect in the sequence?” This field has the answer: it’s the value that is returned by Sequence.RetrieveSequenceStart.. or a zero value if you leave this field null. You don’t have to use this field, but you’ll find that it comes in very handy if you end up re-ordering your list of effects, using smoothing, or reversing time.