Tiger Expressions Animation Randomizer
Perhaps the most complicated element in this world was the tiger, due to its multiple animations. When the scene first fades in,
the tiger has an intro animation of it jumping into the landscape. After the intro, the tiger cycles through 5 different animated
expressions randomly throughout the experience. While pure randomization in Spark isn't too much of a challenge,
we actually needed a more refined and custom randomizer so that the tiger expressions never repeat consecutively AND
all 5 are animated in a pre-determined random sequence.
To do so, we ended up writing a pretty straighforward "smart" randomizer script. The script pre-shuffles an array of
integer values 1-5 and continuously generates new shuffled arrays one after another. The script also makes sure that the first
value of the new array is not the same as the last value of the old array - this ensures 100% no repeats. At the same time, the
script sends the values out one by one to the patches, telling Spark exactly which tiger animation sequence to play.
The following GIF shows the values logged out onto the console as an example of how the script is working: