SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.


SM Forums / Maya Questions / Programming / IK Leg stretching

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
 
Thread Tools
16-03-2018, 11:12 PM   #1
jesuss196
Registered User
 
Join Date: Jul 2010
Posts: 1
IK Leg stretching
Hi everyone, i'm working on a rig following the tutorial Creating a Comprehensive Character Rig from Maya Learning Channel. I made the left IK leg rig perfect, is stretching, but I'm doing the right leg and when i used the same Mel script, it doesn't work, I think maybe is because the Translation X in the left is positive and in the right is negative, I need help with that.

This is the script:

string $driver = "dist_l_length_IK0Shape1.distance";
float $leftThighLength = `getAttr jDrv_l_knee_IK01.translateX`;
float $leftKneeLength = `getAttr jDrv_l_ankle_IK01.translateX`;
float $sumLength = $leftThighLength + $leftKneeLength;

setDrivenKeyframe -currentDriver $driver -driverValue $sumLength -attribute "translateX" -value $leftThighLength jDrv_l_knee_IK01;

setDrivenKeyframe -currentDriver $driver -driverValue ($sumLength*2) -attribute "translateX" -value ($leftThighLength*2) jDrv_l_knee_IK01;

setDrivenKeyframe -currentDriver $driver -driverValue $sumLength -attribute "translateX" -value $leftKneeLength jDrv_l_ankle_IK01;

setDrivenKeyframe -currentDriver $driver -driverValue ($sumLength*2) -attribute "translateX" -value ($leftKneeLength*2) jDrv_l_ankle_IK01;

That's for left Leg, of course I substitute the left for the right and the "l" for the "r".

The answaer me an tell me that I need to multiply the various stretch equations by -1, but muy question is where exactly in the equation i have to multiply by -1.

Hope you can help me.
  Reply with quote
29-01-2020, 02:32 PM   #2
AverageRigger
Registered User
 
Join Date: Jan 2020
Posts: 2
I consumed alot of tutorials on rigging and this channel is one of the better ones on Youtube

Hardcoded within this script it will always look for left sided objects because the names are set like "dist_l_length_IK0Shape1.distance".

"dist_L_length_ ..."

So in order to make the script work for the right side you have to switch out all "_l_" to "_r_" in the script.
I recommend not doing this by hand but by copy the script and paste it into f.e. ms word and do a search&replace so you don't miss any _l_ by accident.

Hope that helps
greets Oliver

Last edited by AverageRigger; 29-01-2020 at 02:39 PM.
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
FK <=> IK Switch zzz7net Animation 0 10-12-2014 03:20 AM
ewbie help adding ik handles to legs, i cant do it sortedford Maya Basics & Newbie Lounge 2 03-04-2006 02:49 PM
dog back leg ik olivermagno Animation 1 20-06-2003 12:17 PM
IK DukerX Animation 2 20-04-2003 01:56 AM
Getting IK to work in reverse... dkouts Animation 9 02-12-2002 04:38 PM