AddTarget - Float scripts

Hello,

How can i use the AddTarget option in float scripts? I dont't want to write a new script to solve this problem, but where i have to write this "AddTarget" to make it works, and what i have to write punctually?...

I searched for solution on scriptspot and cgtalk, but i didn't found what i want, only separated scripts which solve this, i think (hope) it could works without any other scripts...

For example: There is three spheres. (Sphere01, Sphere02, Sphere03). I give to the Sphere01 that it's position controller be a float script, and in this script write that "$Sphere02.pos". So it will be always where the Sphere02 is. But if i link the Sphere02 to the Sphere03, and i move the Sphere03, the 01 is not updated by the script. Only when i move the Sphere02...

What i have to do in this case?

Thanks the answer(s) in advance!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Matyrix's picture

So... I want to use the

So... I want to use the AddTarget option in float script. Because i have a character rig, and there are a lot of cases where is a good opportunity the AddTarget.
This is why i wrote this little example, because more easy to comment on it.

This sphere example is not my problem, it's just a little model of my problem.

The problem is AddTarget usage.

So please if anybody knows how can i use this AddTarget (what is the right usage by an example, and where i have to write this), please let me know.

Thanks in advance and thanks the comments! :)

Anubis's picture

Hi Matyrix, an example for

Hi Matyrix, an example for AddTarget usage is available in the help - "float_script - FloatController > Target (Track) Variable". I hope this helps.

-- Example from the help:
obj1 = Teapot() --Create a teapot
obj2 = instance obj1 --Create an instance
obj2.pos = [-100,0,0] --Place the instance 100 units along -X
obj3 = Box pos:[100,0,0] --Create a box 100 units long X
ctrl = float_script()--Create a Float Script Controller
obj3.height.controller = ctrl --Assign Controller to Height of Box
ctrl.addTarget "myTeapot" obj1[4] --Add Target Var. with Teapot Obj.
ctrl.setExpression "myTeapot.Radius" --Set Height to Teapot Radius
ctrl.getTarget "myTeapot" --Get the Target Track as SubAnim value
ctrl.getTarget "myTeapot" asObject:true --Get as Object
ctrl.PrintDetails()--Print the controller details

my recent MAXScripts RSS (archive here)

Matyrix's picture

Really thanks! I don't know

Really thanks! I don't know how could i not found this. But... What the hell is the [4] in the "ctrl.addTarget "myTeapot" obj1[4]" line? :)

Anubis's picture

Check for "SubAnims" (Indexed

Check for "SubAnims" (Indexed Access to Animatable Properties) :)

obj1 = Teapot()
obj1[1] --SubAnim:Visibility
obj1[2] --SubAnim:Space_Warps
obj1[3] --SubAnim:Transform
obj1[4] --SubAnim:Object__Teapot
obj1[5] --SubAnim:Material
obj1[6] --SubAnim:Image_Motion_Blur_Multiplier
obj1[7] --SubAnim:Object_Motion_Blur_On_Off
getSubAnimNames obj1 -- #(#visibility, #Space_Warps, #transform, #Object__Teapot, #material, #Image_Motion_Blur_Multiplier, #Object_Motion_Blur_On_Off)
obj1[4].object -- Teapot
obj1[4].numSubs -- 7
getSubAnimNames obj1[4] -- #(#radius, #Segments, #smooth, #body, #handle, #spout, #lid)

my recent MAXScripts RSS (archive here)

Matyrix's picture

Thanks again! This helped me

Thanks again! This helped me a lot. But... I couldn't use it to solve my problem.
I recorded my problem and uploaded here as a video:
http://vimeo.com/14942897

What is the easiest way to solve this?

Anubis's picture

Strangely, wiring fail, but

Strangely, wiring fail, but float script works here (Max 2009), just as Veneta said, need to move slider to update the controller. Here is my test (screenshot) - I wrote "$Box02.pos[3]" in the expression (without adding target).

AttachmentSize
float_script_z.png 4.7 KB

my recent MAXScripts RSS (archive here)

Matyrix's picture

It's really interesting. So

It's really interesting. So the main problem was the target usage.. hm.
But thanks your help again! It's work from now, and i forgot the wire parameters for a long time. :)

veneta's picture

I not see any problem. In the

I not see any problem. In the described example shpere01 follow sphere02 position even if sphere02 is linked to sphere03 and sphere03 is moved, just need to move the slider to update ;)

Matyrix's picture

Hmm, what is the version of

Hmm, what is the version of your max? I moved the slider but nothing changed... I use 2009.

By the way i hope somebody knows how could be used the AddTarget option :)

Anubis's picture

You can instance Sphere01 and

You can instance Sphere01 and Sphere02 position controllers.
The float script will not necessary in this case.

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.