言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Animator.SetIKRotation

Switch to Manual
public function SetIKRotation(goal: AvatarIKGoal, goalRotation: Quaternion): void;

Parameters

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

Description

IKゴールの回転(Rotation)を設定します

IK ゴールは特定のボディパーツのターゲット位置および回転です。Unity により開始位置からパーツをターゲットに向けて移動する方法を計算できます(すなわちアニメーションから取得された現在の位置および回転)。 この関数によりワールド座標での回転の最終的なゴールをセットします。空間上でボディパーツが実際に辿りつく場所は、IK がスタートからゴールの間のどこを目指すか 0 から 1 の間の値で示すウェイトパラメータによっても影響を受けます。

var objToAimAt: Transform;

private var animator: Animator;


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


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