Interface – Connecting Attributes

As my assisting tool was using sliders, I wanted those sliders to have meaningful number scales. I chose 0 – 100 as the default as its a good whole number, understandable and often associated with a percentage which works well for most of the sliders I’ve used. For example the storm master slider, goes from 0 – 100 where 0 is turned off and 100 is 100% storm intensity.

From the start, I wanted things like “Time” to be a little easier to understand so 0 – 24 seemed more appropriate. Yes I could have made this anything, it is an alien planet after all and days could be longer, but for the sake of usability: 7 is morning, 12 is midday, 8 is evening, etc.

Originally I used the maya command:

maya.cmds.connectControl(scene_time, “grp_light_control.rotateX”) where the group held a light whose pivot rotated around the scene. For testing purposes I had to set the slider from 0 – 360 to work.

To get a better slider scale to work I was first a little stumped. I thought I’d have to add new attributes to objects with a scale I wanted, then use the hypershade editor to connect them to the existing attributes that needed to be controlled. Although I did need new attributes, set driven key was the solution.

Simply, I had to create a new attribute on the object I was controlling, so for the light control I added a variable named scene_time which had a minimum of 0 and maximum of 24. I then used set driven key to key the object’s rotation (where 0 was 0 and 24 was 360). And now I have sliders that are appropriately scaled, hooray.

Leave a Reply