View Full Version : if statement expression for controller

11 November 2012, 02:00 PM
Hi guys

I have had some problems with my rig setup of a mini cooper austin, my rig is almost complete, but the wipers on the wind shield are left.

I used SDK (set driven keys) for the wipers, i made a new attribute in the attirbute section of each wiper itself, freezed the translate and scale of the wipers, so just rotation and the new attribute was left. the new attribute was given a limit 0-1. so the new attribute drives the rotation of the wipers. it works perfectly, but i am stuck writing an expression for making a controller for the wipers. so they both move simultaneously together.

This is what i have so far:

// wind shield wipers

if(TopControl_mini01.wipers == 0){

Wiper_left01.wiperleft = time * 500;

}else if(TopControl_mini01.wipers == 1){

Wiper_left01.wiperleft = time * 0;

i dont know how to set the condition where both wipers starts automatically rotating when the controller's attirbute is set to 1, so they keep wiping the window!

any tips? thanks in advance

11 November 2012, 12:08 PM
make attributes:

wiper.alwaysAnimate = sin(time) * 180; ---> Expression or loopable keyframe
wiper.trigger = 1; -------------------------------> Keep it between 0 to 1

wiper.rotateZ = wiper.alwaysAnimate * wiper.trigger; ----> This is the one that actually do the animation on the wiper geo

you key wiper.trigger between 0 (still) to 1 (wiping). Anything in between is the speed difference.

Let us know how it goes

11 November 2012, 06:16 PM
hey man...

thanks alot of the tips... it finally worked out... i made a new attribute that controls the rotation of wipers, then i used set driven keys.

the new attribute(wipers) controls the rotation of the wipers smoothly, then i made a new attribute in my controller for turning the wipers On and off, then i wrote an expression. it works fine. here is the expression i wrote:

// wipers

if(TopControl_mini01.wipers_on_off == 0){

Wiper_right01.wiperright = 0 * (cos (9.5 * time));
Wiper_left01.wiperleft = 0 * (cos (9.5 * time));

}else if(TopControl_mini01.wipers_on_off == 1){

Wiper_right01.wiperright = -1 * (cos (9.5 * time));
Wiper_left01.wiperleft = -1 * (cos (9.5 * time));

thanks for the tip again and following up, now i need a software that i can record my desktop screen to make a video for showing the features of my rig???

any ideas??

CGTalk Moderation
11 November 2012, 06:16 PM
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.