PDA

View Full Version : Position constraint-float script question


filanek
10-30-2007, 05:38 AM
Hi, could someone help me please to sort this problem?
I have an object with position constraint and float script controller.
I would like to change the object name "$man01." to something, what could
automatically recognize the root/parent object's name. Is it possible?
see attchad image http://zelosh.zoomshare.com/files/script_controller.jpg

I want to apply this script controller to more objects without retyping manually
its name in every script...

Thanks,
filip

focomoso
10-30-2007, 07:05 AM
In general, you shouldn't be referencing objects with $ notation in a script controller. Better practice is to add the objects you want to use as node variables and access them that way. Then you can change the names of the objects as much as you want and the script doesn't care because it knows the object's id. (Not sure if this answers your question, though...)

filanek
10-30-2007, 08:44 AM
Thanks mate;)
You helped me a lot!
cheers
filip

Mathieson
10-30-2007, 02:17 PM
You can use,

(for x in refs.dependents(this) where isValidNode x collect x)[1].parent

to replace $man01, although its not very efficient and might not work properly if the controller is instanced over several objects.

I'd do what focomoso suggested and then, with the object selected, execute this code in the listener..


$.pos.controller.position_script.controller.setNode "par" $.parent


Assuming you've named your variable "par", it will automatically set the value of "par" to the node that is the parent of the selected object.

EDIT: Theres not supposed to be a tab in .setNode

filanek
11-07-2007, 02:30 AM
Thanks Mathieson!
this "(for x in refs.dependents(this) where isValidNode x collect x)[1].parent" works exactly the way I wanted;)
cheers
filip

CGTalk Moderation
11-07-2007, 02:30 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.