お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
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 |
goalPosition | ワールド空間での位置 |
IKゴールの位置を設定します。
IK ゴールは特定のボディパーツのターゲット位置および回転です。Unity により開始位置からパーツをターゲットに向けて移動する方法を計算できます(すなわちアニメーションから取得された現在の位置および回転)。 この関数によりワールド座標での最終的なゴールをセットします。空間上でボディパーツが実際に辿りつく場所は、IK がスタートからゴールの間のどこを目指すか 0 から 1 の間の値で示すウェイトパラメータによっても影響を受けます。
var objToPickUp: Transform; private var animator: Animator; function Start() { animator = GetComponent.<Animator>(); } function OnAnimatorIK(layerIndex: int) { var reach: float = animator.GetFloat("RightHandReach"); animator.SetIKPositionWeight(AvatarIKGoal.RightHand, reach); animator.SetIKPosition(AvatarIKGoal.RightHand, objToPickUp.position); }
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); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): public objToPickUp as Transform private animator as Animator def Start() as void: animator = GetComponent[of Animator]() def OnAnimatorIK(layerIndex as int) as void: reach as float = animator.GetFloat('RightHandReach') animator.SetIKPositionWeight(AvatarIKGoal.RightHand, reach) animator.SetIKPosition(AvatarIKGoal.RightHand, objToPickUp.position)
See Also: SetIKPositionWeight, SetIKRotation.