View Full Version : Is there any way in MAX to freeze a stretchy leg...
05-22-2006, 09:27 AM
...once it's stretched to its defined limit. Basically I want to stretch a leg to a point and then freeze the stretchyness so that I can still bend the knees afterwards and walk on really long legs.
I'm using the basic stretchy legs script (thanks to whoever wrote it - sorry I don't know who did) where it stretches once the IK chain completely extends. Have a look at the following code;
dependsOn $IKC_L_Ankle $B_L_Hip $CNTRL_Foot;
--Get Values from Custom Attributes
freezeStretch = $CNTRL_Foot.modifiers[#Attribute_Holder].Custom_Attributes[#Freeze_Stretch].value
allowedStretch = $CNTRL_Foot.modifiers[#Attribute_Holder].Custom_Attributes[#Stretch_Amount].value
d = distance $IKC_L_Ankle.pos $B_L_UpperLeg.pos;
leng = $B_L_UpperLeg.length + $B_L_LowerLeg.length
stretch = (d - leng);
orig = $B_L_UpperLeg.length
if (stretch > allowedStretch) then stretch = allowedStretch;
if (stretch < 0) then stretch = 0;
stretchP = orig + (stretch/2);
--if freezeStretch == true then <freeze length/position here, how?> else sp = stretchP
I've got two custom attributes (these are on the foot spline if you download the file) - one that defines the limit and the other is a boolean button which when pressed will freeze the stretch so that I can use the long legs. I was trying to put it in that last line (don't ask how) but couldn't get it to work (obviously).
Would this be the proper method to go about doing this? If not, how could I achieve this effect?
Any help would be greatly appreciated and just incase you wanted to have a look at the file I have attached it. I'm very new to Maxscript and rigging so sorry for my ignorance on this matter.
05-22-2006, 01:35 PM
I'm not sure if this is what you're looking for but on the autodesk website there is a video about the new features of max 8 that seems quite relevant to your question. The controller video shows a stretchy leg set up with a limit controller linked to a sphere by a script to determine the "floor".
look for the Controller video
05-22-2006, 10:38 PM
Thanks Josh - Unfrotunately though, that's not what I'm looking for at this point. See how in the video the leg stretchhes once it's extended - I am looking for a way to freeze the stretch at any given point so that the legs are longer than when I started, this way I can have a character who's legs can stretch and shrink while still working with the IK Chain at different lengths - meaning being able to bend the knees after freezing the stretch amount at say 150%.
For example: Start with a character with legs that are 100 units long. Outstretch this to 150 units and freeze the stretch - Now my legs are longer and I can still animate the stretch. Then unfreeze the stretch to return his legs to the original length - At this point I guess the legs would still stretch as they would be longer than the default and would be trying to get back to that length, but I would just animate the body down.
hmmm...sounds a bit confusing. Hope you understand.
05-22-2006, 10:43 PM
I made it work but I prefer using an expression rather than a script controller. Sometimes they fail when you open the file and you have to re-evaluate them. One of the things I did was add a script to the checkbutton on your custom attribute modifier. The easiest way to edit a custom attributes script is with a script that Paul Neale wrote.
http://www.paulneale.com/scripts/PEN_Rigging_Utils_4-01.zip I took the attribute editor out of his script tools and use it just by itself. What does it do? You can select a node in your scene and it shows a list of the custom attributes on it. Then you can open the script of that custom attribute and edit it by hand. This allows you to put more of your scripts on the custom attribute instead of inside script controllers ect. I generaly put all the scripts I want our animators to use on the custom attribute modifier that way they dont need to load external scripts.
I also added a new attribute freezeAmount that allows the frozen amount to be animated.
Hope that helps,
05-23-2006, 12:33 AM
Dude, you're a legend!!! Not only did you fix my problem but also answered a question I was about to post - How to write expressions like the one for Freeze Amount, where it's not actually on an object's parameter (like the position script).
Thanks a lot Ryan, much appreciated.
Hey Ryan I have never run into script controllers failing when you reload the file. CAn I ask what was causing it? If you are loading Max7 files that are using dependsOn statements I can see that there might be a problem but if they are Max 8 files and the new script controller has been used correctly I can't see that happening. That said if you have a series of events that will recreate the issue I would love to hear about it.
05-23-2006, 04:52 PM
Hey Paul, yes my problem was the old script controller in max 7. Which is what he is currently using. I honestly havent tried using the new script controllers much. I think I had a unrational fear of them after max 7. So I take what I said earlier back, if your using max 8 the script controller should work fine for you.
05-23-2006, 04:52 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.