Script Controller

The Script Controller is an animation controller that evaluates a math formula and return its result to the track. For instance, you can create a formula that will make the Bend value half of the Twist Value. The Script Controller has more flexibility and is easier to use than Expression Controllers.

There are two ways to assign a Script Controller. First one is through Track View or Motion Panel. The second one is through MAXScript.

You will now create a Script Controller that will specify that the Bend value is half of the Twist value.

Create a cylinder:

  • Type: cyl = cylinder radius:20 height:100 heightsegs:20
  • Type: addmodifier cyl (Bend()) and addmodifier cyl (Twist())
  • Open Track View
  • Select Cylinder/Modified Object/Bend/Angle
  • Using Assign Controller, assign a Float Script Controller
  • Right click it and select Properties
  • Type $Cylinder01.Twist.Angle/2 and click Evaluate


If you change a script controller, the changes will not be shown in the screen, until the current time has changed. To view the changes on screen, advance one frame, and return back one frame. This way you will view the changes.

Specify a 30º Twist and notice the Bend being modified.

Now create an animation with Twist ranging from 0 to 180º.

Another example of Script Controller is to assign it to a Optimize Modifier and adjust the optimizer according to the distance between the object and the camera.

To execute it, create the objects below:

  • Type:
    cyl = cylinder radius:20 height:100 heightsegs:20 name:"Cyl"
    cam = freecamera pos:[0,-200,120] name:"Cam"
    cam.rotation.x_rotation = 70

Add a Optimize Modifier to the cylinder, manually, and change the Perspective View to a Camera View.

In the Track View, add a Float Script Controller to the Face Threshold L1 in this object's Optimize Modifier.

Select Properties and observe the value displayed in the field. This value (0.0698132) is the value displayed in the Modify Panel, but it's in radians.


The formula to be typed is the following:

4*(pi*2/360)*((distance $Cam $Cyl) - 200)/(500 - 200) where:

4 is the final value (highest) of the Optimize Threshold
pi*2/360 is the conversion to radians
200 is the minimum distance from the object to the camera, where Optimize is zero
500 is the biggest distance between the object and the camera, where Optimize is 4 (the value above)

The values used above (4, 200, 500) can be altered according to each scene, as well as the object names.


Now you will see it working. Increase the number of Height Segments of the cylinder and add a Noise Modifier prior to the Optimize. Animate the object from scene 0 to 100, moving it closer to the camera in frame 0 and about 600 units far, in frame 100. Play the animation and observe the object's optimization.

If you prefer, you can download the optimize_script.max file, which already contains all these changes.

Alexander Esppeschit Bicalho © 1999