goal | The AvatarIKGoal that is set. |
goalRotation | The rotation in world space. |
Sets the rotation of an IK goal.
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 Example : 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 Example(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)