Version: 2017.1

Animator.SetIKPosition

切换到手册
public void SetIKPosition (AvatarIKGoal goal, Vector3 goalPosition);

参数

goal 设置的 AvatarIKGoal。
goalPosition 在世界空间中的位置。

描述

设置反向动力学目标的位置。

反向动力学目标是特定身体部位的目标位置和旋转。Unity 能够计算如何将身体部位从起点(即,从动画中获得的当前位置和旋转)向目标移动。

该函数设置最终目标在世界空间中的位置;身体部位最终在空间中的实际点也受到权重参数的影响,权重参数指定起点与反向动力学应瞄准的目标之间的距离(范围 0..1 之间的值)。

This function should always be called in MonoBehavior.OnAnimatorIK, if.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform objToPickUp; private Animator animator; void Start() { animator = GetComponent<Animator>(); } void OnAnimatorIK(int layerIndex) { float reach = animator.GetFloat("RightHandReach"); animator.SetIKPositionWeight(AvatarIKGoal.RightHand, reach); animator.SetIKPosition(AvatarIKGoal.RightHand, objToPickUp.position); } }

另请参阅:SetIKPositionWeightSetIKRotation