Question about custom attribute in rig


#1

hi, i add a custom attribute in my controller, and my question is how can i make it to do automatic animation like, the one in metal fly rig, when i change the value of the fly controller to 1-10 his fly automatically move. how can i do something like that. thanks


#2

Hi
Do u mean the flap of a wing connected to an attribute?
you can do by connecting the attribute to a multiply/divide node input 1x and the time (u will get it when you open DAG nodes) to input 2x. Finally connect the output x to the Rotation axis of the fly’s wing. Result play the time line you can see it. The attribute value will have the control on the speed of the wing flap.
Rgds,


#3

Hi ffpc123,

for me the easiest way to achieve that kind of control is to use Maya “sine” function.
To do this you have to do 2 things, add some custom Attributes and set an expression on the wing rotation. Try it on some cubes first, so create 3 cubes, one at the center and name it “body” and one on each side of the “body” cube and name them wing_right and wing_left.

Now add custom attributes to your “body” cube: amplitude, frequency, offset and rotOffset. Then open the expression editor (Window–>Animation Editors–>expression editor) and write this simple expression.

$amplitude = body.amplitude;
$frequency = body.frequency;
$offset = body.offset;
$rotationOffset = body.rotOffset;

wing_right.rotateZ = (sin((time*$frequency)+$offset)*$amplitude)+$rotationOffset;
wing_left.rotateZ = -1*(sin((time*$frequency)+$offset)*$amplitude)+($rotationOffset*-1);

the first part is only to collect the values of custom parameters added on the body and to make easier to write the expression for the two wings.

the second part is the expression that drives wings rotations. Aplitude is used to set how much the wings flaps, frequency sets how fast, offset is to offset the flap in time and rotationOffset is used to make them flap higher or lower.

note that on left wing i multiply the expression by “-1” and be sure that objects and attributes names in the expression and in the scene are the same.

on the link below you can find an example file, hope you can find it of some help. :wink:

Wings.mb

cheers,
Giulio


#4

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.