Notifications
Clear all

[Closed] Retargeting script controller targets post-merge

I’m interested in retargeting Script Controller targets after a merge operation.

A merged node with a script controller will lose its target, assuming the target wasn’t merged along with it. I know I can reassign the target with the [iScriptCtrl].setTarget() method, but is there any way to automatically know what the target should be?

For example, if I’m merging a Teapot that targets Sphere001’s Z Position in a script controller, can I know, post-merge, that the Teapot’s script controller was pointed to $Sphere001’s Z Position instead of ” Track: <<Position XYZ instance>>.‘Z Position’ “.

Thanks!

3 Replies

there is no simple way to know what original target was…
but you can take care about this situation yourself. let’s say create extra constant variable for this scripted controller with name of used target
something like this:

delete objects
b = point size:10 box:on
s = sphere radius:10 pos:[20,0,0]
c = s.pos.controller[3].controller = float_script()
c.addtarget "z" b.pos.controller[3] 
c.addconstant "anim" (exprForMAXObject b.pos.controller[3])
c.setexpression "z"

Perfect!

I suspected I’d need to store the data in the incoming merged node, and I was thinking custom attributes or some other method. I like the elegance of everything being self-contained in the script controller itself.

Many thanks.

that was exactly the goal