Version: 2022.3
言語: 日本語
public void SetIKPosition (AvatarIKGoal goal, Vector3 goalPosition);

パラメーター

goal 設定した AvatarIKGoal
goalPosition ワールド空間での位置

説明

IK ゴールの位置を設定します。

IK ゴールは特定のボディパーツのターゲット位置および回転です。Unity により開始位置からパーツをターゲットに向けて移動する方法を計算できます(すなわちアニメーションから取得された現在の位置および回転)。

この関数によりワールド座標での回転の最終的なゴールをセットします。空間上でボディパーツが実際にたどりつく場所は、IK がスタートからゴールの間のどこを目指すかを 0 から 1 の間の値で示すウェイトパラメーターによっても影響を受けます。

This function should always be called in MonoBehaviour.OnAnimatorIK.

using UnityEngine;

public class Example : MonoBehaviour { Transform objToPickUp; 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); } }