Version: 2017.2

MonoBehaviour.OnAnimatorIK(int)

切换到手册

参数

layerIndex 调用反向动力学解算器的层的索引。

描述

用于设置动画 IK(反向运动学)的回调。

OnAnimatorIK() 在即将更新其内部反向动力学系统前由动画器组件调用。该回调可用于设置反向动力学目标的位置及其各自的权重。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public float leftFootPositionWeight; public float leftFootRotationWeight; public Transform leftFootObj; private Animator animator; void Start() { animator = GetComponent<Animator>(); } void OnAnimatorIK(int layerIndex) { animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, leftFootPositionWeight); animator.SetIKRotationWeight(AvatarIKGoal.LeftFoot, leftFootRotationWeight); animator.SetIKPosition(AvatarIKGoal.LeftFoot, leftFootObj.position); animator.SetIKRotation(AvatarIKGoal.LeftFoot, leftFootObj.rotation); } }