お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closegoal | 設定したAvatarIKGoal |
goalRotation | ワールド空間での位置 |
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); }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public Transform objToAimAt; private 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); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): public objToAimAt as Transform private animator as Animator def Start() as void: animator = GetComponent[of Animator]() def OnAnimatorIK(layerIndex as int) as void: handRotation as Quaternion = Quaternion.LookRotation((objToAimAt.position - transform.position)) animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1.0F) animator.SetIKRotation(AvatarIKGoal.RightHand, handRotation)
See Also: SetIKRotationWeight, SetIKPosition.