View Full Version : Using Maxscript generates Escalator Animation v1.0

16-05-2007, 01:53 AM
Please correct me if it's wrong.

Using Maxscript generates Escalator Animation v1.0

Why we need to use maxscript to generate escalator animation?
1. When using path constraint and turn on “Follow”, the object flips unreasonably.

2. If turn off “Follow” at Path Constraint, and animate the escalator steps rotation manually, it becomes repetitive burden if there are thousands of steps. The following is an animated gif of duplicated escalator steps, with same rotation keyframes but different “% Along Path”. Will you spends hour to move the keys with your hand?

16-05-2007, 01:56 AM
How to use this script?
1. Preparing a rectangle spline path (any length, width and corner radius), called Rectangle01, and make sure the “first vertex” is at your right hand top:

2. After applying path constraint to escalator step (called Box01) by using Rectangle01 path, animate “% Along Path” to 200 (or 300, 350 etc, minimum is 200) at frame 100. This value is called var3 in the script.

3. Find out which frames the escalator step starts and ends rotating. So we have
var2 = 18 --1st keyframe, when rotation 0.
var4 = 25 --2nd keyframe, when rotation 180.

4. From the menu, click Maxscript > New Script, copy and paste the following code and edit the values. Then click CTRL+E (File > Evaluate All).

--Value that you could change
numbox = 25 --Total of box/escalator step.
var1 = 4 --Time interval (%Along Path" of Path constraint) between boxes. Smaller value causes smaller gaps between boxes.
var3 = 200 as float --Speed, minimum 200, must same with last animation keyframe: "%Along Path" of Path constraint.
var2 = 18 --1st keyframe, when rotation 0.
var4 = 25 --2nd keyframe, when rotation 180.

--DONOT change these
endframe = 100 as float --End Time, you could re-scale time manually at Time Configuration dialog after running this script.
period = var3/endframe
animationRange = interval 0 endframe
set coordsys local
myarray = #()
myarray[1] = $Box01
$Box01.pos.controller = path follow:false
PosCont.path= $Rectangle01
animate on(at time endframe $Box01.pos.controller.percent=var3)

for i=2 to numbox do
myarray[i] = instance myarray[1]
myarray[i].pos.controller.percent = (i-1)*(-var1)

for j=1 to myarray.count do
myarray[j].wirecolor = (color 88 199 255)
animate on(
for k=0 to (period-1) do
at time (endframe/(var3/var2/(var3/100))*1 + (endframe/period)*k + (var1*100/var3)*(j-1)) rotate myarray[j] (quat 0 y_axis)
at time (endframe/(var3/var2/(var3/100))*1+(var4-var2) + (endframe/period)*k + (var1*100/var3)*(j-1)) rotate myarray[j] (quat 180 y_axis)
at time (endframe/(var3/var2/(var3/100))*2+(var4-var2) + (endframe/period)*k + (var1*100/var3)*(j-1)) rotate myarray[j] (quat 0 y_axis)
at time (endframe/(var3/var2/(var3/100))*2+2*(var4-var2) + (endframe/period)*k + (var1*100/var3)*(j-1)) rotate myarray[j] (quat 180 y_axis)
animationRange = interval 50 endframe

5. It runs, but speed too fast. So we need to re-scale the animation. We have to set the start time to zero first, then res-scale time.

Animation before scaling time:

Animation after scaling time:

That's all. Please correct me if anything's wrong.

09-06-2007, 01:53 PM
Great script, works like a charm for many things, I used it to send sparks along a wire and a bunch of water drops in anther animation.

Now I might aim to incorporate an escalator in some future animation just for the reason to use this script in it's proper way heh