お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
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 の範囲のウェイト値をセットします。位置そのものは SetIKRotation を使用して別にセットされます。
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: SetIKRotation, SetIKPositionWeight.