Version: 2020.3

Animator.SetIKRotation

切换到手册
public void SetIKRotation (AvatarIKGoal goal, Quaternion goalRotation);

参数

goal 设置的 AvatarIKGoal。
goalRotation 在世界空间中的旋转。

描述

设置反向动力学目标的旋转。

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

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

using UnityEngine;

public class Example : MonoBehaviour { Transform objToAimAt; Animator animator;

void Start() { animator = GetComponent<Animator>(); }

void OnAnimatorIK(int layerIndex) { Quaternion handRotation = Quaternion.LookRotation(objToAimAt.position - transform.position); animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1.0f); animator.SetIKRotation(AvatarIKGoal.RightHand, handRotation); } }

另请参阅:SetIKRotationWeightSetIKPosition

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961