dependsOn For Scripted Controllers

This is obsolete in 3ds Max 8. Assign Nodes to User Variables instead.

dependsOn was used with scripted controllers in versions prior to 3ds Max 8 to enable interactive update of scripted controllers when the code in them depends on other objects in the scene. Place a call to dependsOn in the controller script somewhere (usually at the top), with a list of objects on which the controller depends. Interactive changes to any of these objects will cause the object containing the script controller to also update.


A $foo.pos controller script:

dependsOn $foo2 $foo3

($foo2.pos + $foo3.pos) / 2

will always keep $foo centered between $foo1 and $foo2. The objects given to the dependsOn() function can be any MAX object, controllers, base object, nodes, materials, etc. They must be individual, explicit objects, not wild-card path names or arrays of objects. The object can be the exact controller you want to depend on or any containing object. The strict dependency for the above script would be,


dependsOn $foo2.pos.controller $foo3.pos.controller

The simpler $foo2 $foo3 will catch *any* kind of changes to those nodes or components in them like base objects, modifiers, or materials and update the script-controlled object. The dependency is established the first time the controller is evaluated after any script change or recompile. This can be when editing in a controller property box, or after a scene load.

You can programmatically force a recompile and reset of the dependents by setting the control script to itself:

$foo.pos.controller.script = $foo.pos.controller.script

See also

Script Controllers

'This' Local Variable in Scripted Controllers