Hack 31 Hacking The Matrix

figs/moderate.gif figs/hack31.gif

Quickly re-create the famous falling green text effect from The Matrix.

Suppose we want to make a quick, nonscripted version of the green letter waterfall effect from The Matrix film trilogy. This effect consists of lots of randomly falling, reversed Katakana characters (see http://japanese.about.com/library/weekly/aa052103a.htm for details on Katakana).

The first symbol, named text, is a simple three-keyframe timeline, as shown in Figure 4-8.

Figure 4-8. A three-keyframe timeline for our text symbol

The three keyframes display the three static text fields shown in Figure 4-9. Although this is a very repetitive animation cycle, nobody will notice because it happens so fast.

Figure 4-9. Three static text fields to be used as the basis for our animation

The Matrix waterfall effect consists of lots of these text streams falling randomly down the screen over time. To create truly random falling text, we have to do the whole thing with scripts (and judging by a quick look at the online Flash community: (a) not everyone knows how to do this, and (b) a lot of people want to create a Matrix waterfall effect but assume you need to know scripting to do it).

Well, we can't create a truly random animation with just prewritten tweens, but the one presented here repeats only once every 14,535,931 frames (about every two weeks assuming 12 fps), which might as well be random.

The way I did it was to create five tween animations, each within its own movie clip. Each movie clip consists of the text clip falling downward, as shown in Figure 4-10.

Figure 4-10. Movie clip tweened animation showing text falling downward

The difference between the five tweens is that each is a different number of frames long. Movie clip waterfall19 lasts 19 frames, and waterfall37 is a similar animation lasting 37 frames. The five tweens' names are shown in the Library in Figure 4-11.

Figure 4-11. The Library showing movie clip symbols with prime-numbered frame lengths

Figure 4-12 [Hack #30] 19 23 29 31 37 frames must elapse before the effect repeats (a rather long period of time).

Figure 4-12. A three-frame sequence of the final Matrix animation

You'll have to wait a considerable time before the animation repeats if you enjoy a distinct déjà vu feeling. If you are a fan of the first film in the series, you know that déjà vu is a very bad thing and is best avoided, but you'll probably want to add "waterfall" audio to more closely re-create the effect from The Matrix.

Final Thoughts

It's common to watch even a commercially successful animated feature film and see repetitive animation cycles. The main character could be driving down a road, and you will notice that the same combination of scrolling treeline, suburban houses, and parked cars seems to crop up suspiciously regularly. The fact that the same kids are playing in the front garden of every 56th house kinda gives the game away. The reason this has to happen, even in big-budget productions, is that animation is costly, and any time saving that can be made will be made. You don't want to give the game away easily though, and the prime number hack allows you to hide individual animation cycle repetitions by combining them in a way that they do not produce an overall animation that is also extremely repetitive. With increasingly realistic computer-generated effects, even real-life scenes repeat themselves. For example, the crowd in the Washington, D.C. scene in Forrest Gump was really a small tile of people repeated many times. In the movie, The Truman Show, the occupants of the fake town even repeat their movements regularly (cars circle the block, etc.), something which the title character (played by Jim Carrey) comments on.

Back in math class you probably thought prime numbers were only for rocket scientists. Now you know even Tom and Jerry have to use them.

Funny how things work out.