Class · inherits Instance
IKControl
Specifies a control to generate a procedural animation pose using Inverse Kinematics.
About IKControl
IKControl instances generate procedural animation poses using Inverse Kinematics (IK). They allow you to make characters respond realistically to their environment.
For example, you can make a character place its hand on a door handle exactly,
and the character will do so independently of its position.
IKControls provide the advantage of needing to create much
fewer animations for your game while giving your experience a more realistic
and polished feel.
IKControls must be a child of a Humanoid or
AnimationController with an Animator and have all of their
required properties set properly, otherwise they don't have any effect. The
required properties are Type,
EndEffector, Target,
ChainRoot. As soon as those are set, the
IKControl modifies the pose of your character as you specify. The
following code sample demonstrates how to set up your first IKControl
and get started with creating more realistic animations for your game.
You can use IKControls to make a character:
- Rotate its head and torso to look at a point of interest in the world.
- Modify its feet positions to respond to dynamic terrain. Adjust its legs and feet to place them accordingly on terrain with rocks and slopes.
- Hold a gun and place its hands appropriately on the grip without needing to create animations for each gun in the game.
- Aim at a point in the world, so that the tip of the gun point exactly at what you want to shoot. Especially useful in third person shooters.
- Place its hands on the steering wheel of a car and follow it when it rotates.
- Much more!
IKControl will override the animation for all the parts between the
ChainRoot and the
EndEffector. You can enable/disable it using
Enabled or change how much they have an effect over
the underlying animation using the Weight. Be
careful: if you do not set up your IKControls correctly, you
might generate bad and unrealistic poses!
Properties 11
ChainRoot
: InstanceThe last part that you are interested in moving your character. For example, the upper arm. Must be an ancestor ofEndEffectorand be aBasePartor aBonein your character.By specifying a
ChainRootand anEndEffector, you instruct theIKControlthat it's allowed to move and rotate all parts between the two to move theEndEffectorto theTarget. For example, if you specify the LeftHand asEndEffectorand LeftUpperArm as theChainRoot, the control moves 3 parts: the LeftHand, the LeftLowerArm, and the LeftUpperArm. Avoid settingChainRootas the actual root of the character because that produces unrealistic results.Enabled
: booleanToggles the control on and off. True by default.This property allows you to toggle the IK control on and off. It's on by default. When
Enabledis false, the IK control is off and isn't resolved by the underlying solver.EndEffector
: InstanceThe part that you are interested in moving to reach theTarget. For example, the hand of your character. Must be a descendant ofChainRootand be aBasePartor aBonein your character.The
EndEffectordescribes the last part in the chain of your character that you want to affect. For example, it could be the hand when you want to move the whole arm to reach a point. It can be aBaseParton a character, that has aMotor6Das its child, aMotor6Ddirectly, aBone, or aAttachment. The pivot of the selectedEndEffectormoves to theTarget, so you can useAttachmentsto modify which point of aBasePartshould reach theTarget.EndEffectorOffset
: CFrameAn additional offset applied on top of theEndEffectorin its local space to change where it moves.The end-effector offset is an additional
CFrameapplied on top of theTargetCFramethat produces the finalCFrameused to place theEndEffector. By default, it's the identity CFrame, so if you don't set it, it has no effect and theEndEffectoruses theTargetCFramedirectly, which is specified in the local space of theEndEffector.Alternatively, you can use Attachments by setting an Attachment as
EndEffector, which moves it to theTargetinstead of the parts it's attached to, effectively obtaining the same result.You can also use
EndEffectorOffsetto modify which axis of theEndEffectorshould point at theTargetwhen usingLookAtasType.Offset
: CFrameAn additional offset applied on top of theTargetto change where theEndEffectormoves.The offset is an additional
CFrameapplied on top of theTargetCFramethat produces the finalCFrameused to place theEndEffector. It's identity by default, so if you don't set it, it has no effect and theEndEffectorwill use theTargetCFramedirectly. You can animate it to create procedural animations such as typing on a keyboard. It's useful when theTargetandEndEffectoraren't aligned and you need to fix it with an additional rotation or translation.Pole
: InstanceAn optional instance that determines which way the chain bends. You can use this to specify which way an elbow or knee bends.The
Poleis an optionalInstancethat gives you control over how intermediate parts in your character should bend. It can be anything that has a position in the world, such asBasePart,Attachment,Bone,Motor6D. It is by defaultnil. When you specify it, the underlying solver will make the parts bend towards it. When it isnil, the solver will try to make elbows and knees bend appropriately based on the limb of the character. The limb will be "Arm" when you select asEndEffectoreither the LeftHand or RightHand and asChainRootthe corresponding LeftUpperArm or RightUpperArm, and it will be "Leg" when you select asEndEffectoreither the LeftFoot or RightFoot and asChainRootthe corresponding LeftUpperLeg or RightUpperLeg. In all other cases, if you don't specify a pole, the chain might not bend as you expect.Priority
: intSpecifies the order in which controls are solved. Higher values have higher priority.When multiple controls are active on a character, the order in which they are solved by the underlying system affects the final generated pose. By changing this value, you specify the ordering in which controls are satisfied. Higher values have higher priority, and higher-priority controls are resolved later because their result might override the previous result of other controls. If you have multiple IK controls on a character and one is more important than the other, specify a lower priority for it. It is 0 by default, meaning all controls have the same priority.
SmoothTime
: floatSpecifies the average number of seconds that it takes for theEndEffectorto smoothly reach theTarget.This value specifies the average number of seconds that it takes for the
EndEffectorto reach theTarget. The behavior is that of a critically-damped spring, where the rate of change is proportional to the distance to the target and no oscillations are present when approaching the target. Smaller values create a quicker convergence, and larger values create a slower convergence. A value of 0 disables smoothing. The default value is 0.05 to provide a very slight smoothing that makes the motion feel realistic.Target
: InstanceThe object that theEndEffectorreaches for or points at. It can be anything that has a position in the world, such asBasePart,Attachment,Bone, orMotor6D.The
Targetrepresents a point (CFrame) in the world that you want yourEndEffectorto reach. The exact behavior of reaching can be set via theTypeproperty, and an additionalOffsetcan be applied on top of it to modify it. If you set aTargetthat will be moved either by physics or a script, at each frame theIKControlwill try to satisfy it, automatically updating the point to reach.Type
: IKControlTypeSpecifies how the solver satisfies this control.By changing the
Type, you can change the behavior of the control. These are the available options:- Transform: it's a full 6-DoF constraint. Aligns the
EndEffectorCFrameto that of theTarget. - Position: aligns the
EndEffectorposition to that of theTarget. - Rotation: aligns the
EndEffectorrotation to that of theTarget. - LookAt: moves and orients the whole chain to make an axis (by default
the forward axis) on the
EndEffectorpoint at a position in the world specified byTarget.
- Transform: it's a full 6-DoF constraint. Aligns the
Weight
: floatSpecifies the weight of the IK control target. Should be in the [0, 1] range.You can control how much a given control affects the character pose by using this property. Values should be in the [0, 1] range. 0 means no effect, and 1 means full effect of the IK control. Values outside this range are truncated. Smoothly varying this value allows you to blend in or out a specific control to avoid jarring motion. It is 1 by default.
The weight determines the interpolation factor between the End-Effector and the IK target. Setting the weight to 0 doesn't disable the IK Control because other factors, including the SmoothTime smoothing factor and Pole, can still change the pose. To truly disable the IK Control, turn the
Enabledproperty to false.
Methods 6
GetChainCount
() → intReturns the number of segments in the IK chain between theChainRootand theEndEffector.Returns the number of segments in the IK chain, meaning the number of parent-child links between the
ChainRootand theEndEffector. A chain of three parts has a count of2.The chain always has one more node than it has segments, so the valid indices for
GetNodeWorldCFrame()andGetNodeLocalCFrame()range from1to the returned count plus1. This returns0when theIKControldoesn't resolve to a valid chain, such as when its required properties aren't set.GetChainLength
() → floatReturns the total length, in studs, of the IK chain between theChainRootand theEndEffector.Returns the total length of the IK chain in studs, computed as the sum of the world-space distances between each consecutive part from the
EndEffectorup to theChainRoot. This is the maximum reach of the chain: aTargetplaced farther than this distance from the chain's base can't be reached, and the chain extends toward it as far as it can.This returns
0when theIKControldoesn't resolve to a valid chain, such as when its required properties aren't set.GetNodeLocalCFrame
(index: int) → CFrameReturns theCFrameof the chain node at the given index, relative to its parent node in the chain.Returns the
CFrameof the node at the givenindexin the solved IK chain, relative to its parent node. Nodes are ordered from theChainRootat index1to theEndEffectoratGetChainCount()plus1.This reflects the pose most recently produced by the solver. Use
GetNodeWorldCFrame()for the same node in world space. If theindexis outside the valid range, or theIKControlhasn't resolved a valid chain, this returns the identityCFrame.GetNodeWorldCFrame
(index: int) → CFrameReturns the world-spaceCFrameof the chain node at the given index.Returns the world-space
CFrameof the node at the givenindexin the solved IK chain. Nodes are ordered from theChainRootat index1to theEndEffectoratGetChainCount()plus1.This reflects the pose most recently produced by the solver. Use
GetNodeLocalCFrame()for the same node relative to its parent. If theindexis outside the valid range, or theIKControlhasn't resolved a valid chain, this returns the identityCFrame.GetRawFinalTarget
() → CFrameReturns the world-space targetCFramethe solver aims for beforeSmoothTimesmoothing is applied.Returns the
CFramethat the solver aims theEndEffectorat on the current frame, beforeSmoothTimesmoothing is applied. This is theTargetafterWeight,Offset, andEndEffectorOffsetare factored in. For aLookAtType, it's the world position the chain is oriented toward.Compare with
GetSmoothedFinalTarget(), which returns the same target after smoothing. The two are equal whenSmoothTimeis0.GetSmoothedFinalTarget
() → CFrameReturns the world-space targetCFramethe solver aims for afterSmoothTimesmoothing is applied.Returns the
CFramethat the solver aims theEndEffectorat on the current frame, afterSmoothTimesmoothing has been applied to the raw target fromGetRawFinalTarget(). Smoothing uses a critically damped spring that eases toward the raw value over roughlySmoothTimeseconds.Because
SmoothTimedefaults to0.05, this value trailsGetRawFinalTarget()slightly while the target moves. WhenSmoothTimeis0, this returns the sameCFrameasGetRawFinalTarget.
IKControl also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.