This video should be pretty self explanatory:
- The character has no IK before equipping the gun.
- When the gun is equipped, IK targets are set and weight is set to 1.
- When the gun is unequipped, IK targets are unset and weight is set to 0.
- IK still affects the character’s arms and make them flail around weirdly while jumping.
I expect IKControl to no longer affect character animation if the Weight property is set to 0.
Smoothing will apply regardless of the value of the IK weight property. Try setting the Smoothtime property to 0. Alternatively, you may delete the IKControl instance.
Hi, as mentioned by @NotARobloxEngineer, there is the property
IKControl.SmoothTime which smoothes out the motion, even if the weight is set to 0. If you want to completely disable the IKControl, you can set
IKControl.Enabled to false.
Hi @NotARobloxEngineer @sg3cko , thank you for your responses.
SmoothTime still affecting animations even when Weight is set to 0 is unexpected behavior for me as a user and is not documented on the creator docs either - could this behavior be changed? As per the docs for Weight:
Smoothly varying this value allows you to blend in or out a specific control
This sets up the expectation that any properties on IKControl only affect IK, and that Weight is a value between “No IK at all” and “Fully controlled by IK” which I think is reasonable.
You’re right, the doc was misleading. I’ve corrected it, it should be live sometime soon.
The reason why IKControl can still affect the pose with weight=0 is because developers might want to use the weight to e.g. have a character reach for a handle. By simply setting weight=0 or 1, they can have a smooth transition without additional code.
Sorry if I’m understanding this wrong, but is this not what the Target property is for? Setting
.Target = handle and/or
.Target = nil on an IKControl with a high SmoothTime for a low-code but still smooth transition like that? That is exactly how we are currently using it in our game:
I’ll give you some more details on how we are using IK so you can maybe see our problem a bit better. We need to change SmoothTime depending on what the player is doing:
- When releasing the vehicle handle bar, set a high smooth time instantly
- When grabbing the vehicle handle bar, tween towards an instant smooth time so the hand stays on it firmly
- When using a weapon that is attached to the hand, use a quick but not instant smooth time since it may affect aim negatively otherwise, when releasing tween it out, same as above
- Other miscellaneous but similar situations
And when none of these are occurring we would like to completely disable IK to prevent issues like the one in the OP, but still being able to transition smoothly to it. This is currently very difficult to do without hiccups since SmoothTime is not exact (damped spring motion with no way to know when target is reached) and Weight is not actually controlling how much IK is being used. How are we supposed to solve for this?
If you were to set
.Target=nil, the IKControl would stop working altogether. Target is one of the 4 required properties of IKControl (doc here) (the others are
To give you more details about the inner workings:
EndEffector, each specifying a CFrame using a Part or Attachment. On top of those, an offset is applied (
EndEffectorOffset, respectively). The results are lerped using
Weight. This gives a final CFrame (
SmoothTime controls a damped spring that smooths this, returning
:GetSmoothedFinalTarget(), which is the actual CFrame the ik solver uses.
For your use-case, one approach would be:
- When releasing the vehicle handle bar: .Weight=0, .SmoothTime=value that looks good for your use case. You can check when the final pose is close enough to be disabled without popping by comparing
ik:GetSmoothedFinalTarget(). If those are close in position/rotation, disabling the IK using .Enabled=false will not result in a visible pop. Re-enable as needed.
- When grabbing the vehicle handle bar: .Weight=1, tween towards SmoothTime=0
- When using a weapon that is attached to the hand: .Weight=1, .SmoothTime=small
Lmk if that works or if I can help with something else, thanks.