LimbIK扩展了TrigonometricIK以专注于3段手和腿特征肢体类型。
LimbIK配有多个Bend Modifiers:
- Animation:尝试保持动画中的弯曲方向
- Target:使用目标IKRotation旋转折弯方向
- Parent:将弯曲方向与父变换(骨盆或锁骨)一起旋转
- Arm:保持手臂以自然和放松的方式弯曲(也是上述中性能消耗最昂贵的)。
- Goal:将手臂向“Bend Goal”弯曲。
注意:Bend Modifier仅在 Bend Modfier Weight 大于0时应用。
IKSolverLimb.maintainRotationWeight属性允许在解决肢体之前保持固定的最后一个骨骼的世界空间旋转。
当我们需要重新定位一只脚,但是在动画时保持它的旋转以确保与地面正确对齐的时候,这是最有用的。
使用步骤:
- 将LimbIK组件添加到角色的根节点(角色应面向前方)
- 将肢体骨骼分配给LimbIK组件中的bone1,bone2和bone3(可以跳过骨骼,这意味着您还可以在4段肢体上使用LimbIK)。
- 运行
脚本使用:
public LimbIK limbIK;
void LateUpdate () {
// Changing the target position, rotation and weights
limbIK.solver.IKPosition = something;
limbIK.solver.IKRotation = something;
limbIK.solver.IKPositionWeight = something;
limbIK.solver.IKRotationWeight = something;
// Changing the automatic bend modifier
limbIK.solver.bendModifier = IKSolverLimb.BendModifier.Animation; // Will maintain the bending direction as it is animated.
limbIK.solver.bendModifier = IKSolverLimb.BendModifier.Target; // Will bend the limb with the target rotation
limbIK.solver.bendModifier = IKSolverLimb.BendModifier.Parent; // Will bend the limb with the parent bone (pelvis or shoulder)
// Will try to maintain the bend direction in the most biometrically relaxed way for the arms.
// Will not work for the legs.
limbIK.solver.bendModifier = IKSolverLimb.BendModifier.Arm;
}
在运行时添加LimbIK:
- 通过脚本添加LimbIK组件
- 调用LimbIK.solver.SetChain()
LimbIK
组件参数:
- timeStep - 如果为零,将更新每个LateUpdate()中的求解器,用于骨骼带动画时的情况。 如果大于零,将按频率更新,以便求解器将在所有对象上同时到达其目标。
- fixTransforms - 如果为true,则将解算器使用的所有Transforms修复为每个Update中的初始状态。 这可以防止没有动画骨骼和animator的剔除的问题,并且性能成本很低。
求解参数:
- bone1 - 第一根骨头(上臂或大腿)
- bone2 - 第二骨(前臂或小腿)
- bone3 - 第三骨(手或脚)
- target - 目标transform。 如果已分配,则解算器IKPosition和IKRotation将自动设置为目标的位置
- positionWeight - 求解目标位置的权重(IKPosition)
- rotationWeight - 求解目标旋转的权重(IKRotation)
- bendNormal - 由骨骼位置定义的平面的法线。 当肢体弯曲时,第二根骨骼将始终位于该平面上的某个位置
- AvatarIKGoal - 此解算器的AvatarIKGoal。 这仅适用于“Arm”弯曲修改器
- maintainRotationWeight - 在解决之前保持第三个骨骼旋转的权重
- bendModifier - 弯曲法线的自动修改器选择
- bendModifierWeight - 弯曲修改器的权重
LimbIK组件