[Closed] Leg Rig Exploding
Hello Everyone,
I’ve created a tool to help me rig basic legs. It provides IK/FK blending, and sets everything up for you. I’m hoping it will improve my productivity, and it looks like it will, but I’m running into a problem.
It’s exploding.
I know what’s causing it, but I can’t figure out how to fix it.
I’ve set up the rig like so, I have the basic Bone leg consisting of three bones. Those three bones are used to build two more legs. One made of Circles (for FK) and one made of Points (for IK).
A Control Object has a custom modifier with a slider attached to it, and by moving the slider the user can blend between IK and FK. It sounds fairly simple, and it is, my problem is with attaching it to the pelvis.
I don’t want to parent the other two legs to the pelvis bone. I want to keep the Bone hierarchy ‘clean’ because this is going to be used in a game engine. To get around this I’ve added a point in the same location as the pelvis, and orientation and position constrained the point to the pelvis. I’ve then parented the top IKPoint and the top FKCircle to that pelvisPoint.
Should work right?
And it does, unfortunately it leads to their bizzare ‘popping’ that happens whenever you slide the slider back into FK. The leg looks fine, and then when you release the slider it ‘explodes’. The bones are in the correct place, but all of the control objects fly all over the place. If you do anything (change a setting, move the time slider) the control objects pop back into place as if nothing has happened, and when you animate using this leg there doesn’t appear to be any problems, but the ‘exploding’ is very irritating and unprofessional looking.
Does anyone have a good way around this:
There are very few comments in the code as this is only partially complete, but if anyone could figure out why parenting objects to an object that is orientation/position constrained to ANOTHER object would cause this kind of error I would be -immensely- pleased.
rollout JTQlegRigToolRollout "Leg Rigging Tool - V.0.1"
(
fn addlegControls y =
(
local selectedObject = y
local basicIKFKBlend = EmptyModifier name:"IKFK Blend"
addmodifier selectedObject basicIKFKBlend
local IKFKBlend = attributes bIKFKBlend
(
parameters main rollout: blendRollout
(
blendValue type:#float ui:sldBlend default: 0
)
rollout blendRollout "leg Control"
(
slider sldBlend "IK/FK" type:#float range:[0,1,0]
)
)
custAttributes.add selectedObject.IKFK_Blend IKFKBlend
)
group "Pick Bones"
(
pickbutton pickPelvis "Pelvis" across: 2 width: 70
pickbutton pickUpper "Upper leg" width: 70
pickbutton pickLower "Lower leg" across: 2 width: 70
pickbutton pickFoot "Foot" width: 70
)
group "Bend Bone Options"
(
checkbutton kneeBend "Knee" across: 2 width: 70
checkbutton pelvisBend "Pelvis" width: 70
)
group "Complete"
(
button rigButton "Apply Rig" width: 150
)
on rigButton pressed do
(
IKControl_Pelvis = Point cross: on box: off size: 20
IKControl_Pelvis .transform = pickPelvis.object.transform
IKControl_Upper = Point cross: on box: off size: 20
IKControl_Upper.transform = pickUpper.object.transform
IKControl_Lower = Point cross: on box: off size: 20
IKControl_Lower.transform = pickLower.object.transform
IKControl_Foot = Point cross: on box: off size: 20
IKControl_Foot.transform = pickFoot.object.transform
IKControl_Ball = Point cross: on box: off size: 20
IKControl_Ball.transform = pickFoot.object.children[1].transform
mainFootControl = box length: 2 width:(pickFoot.object.length) height:(pickFoot.object.length*1.5)
rotate mainFootControl (angleaxis 180 [0,1,0])
rotate mainFootControl (angleaxis -90 [1,0,0])
rotate mainFootControl (angleaxis -90 [0,0,3])
resettransform mainFootControl
mainFootControl[3][2][3].value = IKControl_Foot[3][2][3].value
mainFootControl[3][1][1].value = IKControl_Foot[3][1][1].value
mainFootControl[3][1][2].value = IKControl_Foot[3][1][2].value
mainFootControl[3][1][3].value = IKControl_Ball[3][1][3].value
IKControl_Foot.parent = IKControl_Lower
IKControl_Lower.parent = IKControl_Upper
IKControl_Upper.parent = IKControl_Pelvis
ikChain = IKSys.ikChain IKControl_Upper IKControl_Foot "IKHISolver"
ikChain.parent = IKControl_Ball
IKControl_Ball.parent = mainFootControl
FKControl_Upper= Circle radius:20 isSelected:off
rotate FKControl_Upper (angleaxis 90 [0,1,0])
resettransform FKControl_Upper
FKControl_Lower = copy FKControl_Upper
FKControl_Foot = copy FKControl_Upper
FKControl_Upper.transform = IKControl_Upper.transform
FKControl_Lower.transform = IKControl_Lower.transform
FKControl_Foot.transform = mainFootControl.transform
FKControl_Foot.parent = FKControl_Lower
FKControl_Lower.parent = FKControl_Upper
FKControl_Upper.parent = IKControl_Pelvis
/*if pickUpper.object.parent != unknown then
(
IKControl_Pelvis.rotation.controller = Orientation_Constraint ()
IKControl_Pelvis[3][2].controller.appendTarget pickPelvis.object 100
IKControl_Pelvis.pos.controller =Position_Constraint ()
IKControl_Pelvis[3][1].controller.appendTarget pickPelvis.object 100
)*/
settransformlockflags FKControl_Upper #{1,2,3,7,8,9}
settransformlockflags FKControl_Lower #{1,2,3,7,8,9}
settransformlockflags FKControl_Foot #{1,2,3,7,8,9}
pickUpper.object.rotation.controller = Orientation_Constraint ()
pickUpper.object[3][2].controller.appendTarget IKControl_Upper 100
pickLower.object.rotation.controller = Orientation_Constraint ()
pickLower.object[3][2].controller.appendTarget IKControl_Lower 100
pickFoot.object.rotation.controller = Orientation_Constraint ()
pickFoot.object[3][2].controller.appendTarget IKControl_Foot 100
IKControl_Foot.transform.controller.FK_Sub_Control.controller.Rotation.controller = LookAt_Constraint ()
IKControl_Foot.transform.controller.FK_Sub_Control.controller.Rotation.controller.relative = on
IKControl_Foot[3][#fk_sub_control][#rotation].appendTarget IKControl_Ball 100
IKControl_Foot.transform.controller.FK_Sub_Control.controller.Rotation.controller.viewline_length_abs = off
addlegControls mainFootControl
--Creates binds the mainFootControl to the FKControl_foot
mainFootControl.pos.controller = position_list ()
mainFootControl.pos.controller.Available.controller = Position_Constraint ()
mainFootControl[3][1][2].controller.appendTarget FKControl_Foot 100
paramWire.connect mainFootControl.modifiers[#IKFK_Blend].bIKFKBlend[#blendValue] mainFootControl[3][1][#Weights][#Weight__Position_Constraint] "blendValue"
mainFootControl.rotation.controller = rotation_list ()
mainFootControl.rotation.controller.Available.controller = Orientation_Constraint ()
mainFootControl[3][2][2].controller.appendTarget FKControl_Foot 100
paramWire.connect mainFootControl.modifiers[#IKFK_Blend].bIKFKBlend[#blendValue] mainFootControl[3][2][#Weights][#Weight__Orientation_Constraint] "blendValue"
--builds and binds the ikAngle Control
ikAngleControl = Rectangle length:35 width:15 cornerRadius:0 isSelected:off
rotate ikAngleControl (angleaxis 90 [1,0,0])
resettransform ikAngleControl
ikAngleControl.transform = pickLower.object.transform
move ikAngleControl [0, (pickLower.object.length/2*-1),0]
ikAngleControl[3][2][1].value = 0
ikAngleControl[3][2][2].value = 0
ikAngleControl[3][2][3].value = 0
ikAngleControl.wirecolor = color 225 198 87
ikChain.transform.controller.VHTarget = ikAngleControl
ikAngleControl.pos.controller = position_list ()
ikAngleControl.pos.controller.Available.controller = Position_Constraint ()
ikAngleControl[3][1][2].controller.appendTarget FKControl_Lower 100
paramWire.connect mainFootControl.modifiers[#IKFK_Blend].bIKFKBlend[#blendValue] ikAngleControl[3][1][#Weights][#Weight__Position_Constraint] "blendValue"
)
)
legRigToolFloat = newrolloutfloater "Leg Tool" 200 220
addrollout JTQlegRigToolRollout legRigToolFloat
I know that this is being caused by the parenting because when I remove the code that adds the parent point the problem stops. The code in question is repeated here:
if pickUpper.object.parent != unknown then
(
IKControl_Pelvis.rotation.controller = Orientation_Constraint ()
IKControl_Pelvis[3][2].controller.appendTarget pickPelvis.object 100
IKControl_Pelvis.pos.controller =Position_Constraint ()
IKControl_Pelvis[3][1].controller.appendTarget pickPelvis.object 100
)
Screenshots:
The first shot shows the leg working using the IK system.
The second shows what happened after I slid the slider entirely to FK and then moved one of the FK bones.
The third shows what happened after I moved the time slider one frame.
I have found an answer, but the precise cause of the problem remains a mystery.
By replacing the Orientation and Position constraints with wired parameters, the problem goes away.
I have noticed… unusual behavious in the past when using the Orientation and Position constraints. Is there any specific reason why these Constraints appear to be… less then stable?