お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
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 |
value | 変更するウェイト |
IK ゴールの移転したウェイトをセットします(0 = IK 前の元のアニメーション位置、1 = ゴール位置)
IK ゴールは特定のボディパーツのターゲット位置および回転です。Unity により開始位置からパーツをターゲットに向けて移動する方法を計算できます(すなわちアニメーションから取得された現在の位置および回転)。 この関数によりスタートからゴールの間のどこを IK が目指すかを示す 0 から 1 の範囲のウェイト値をセットします。位置そのものは SetIKPosition を使用して別にセットされます。
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: SetIKPosition, SetIKRotationWeight.