/// --------------------------------------------- /// Behavior Designer /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.BehaviorDesigner.Samples { using UnityEngine; /// /// Adjusts the hand position according to the specified offset. /// This is used within the Hide and Seek scene allowing the agent to always point the flashlight forward instead of needing a specific animation. /// public class HandAdjustment : MonoBehaviour { [Tooltip("The limb that should be adjusted.")] [SerializeField] protected AvatarIKGoal m_Goal; [Tooltip("The offset from the character's forward rotation.")] [SerializeField] protected Vector3 m_Offset; private Animator m_Animator; /// /// Initializes the default values. /// private void Awake() { m_Animator = GetComponent(); } /// /// Callback when the animator should update IK. /// /// The index of the layer being updated. private void OnAnimatorIK(int layerIndex) { m_Animator.SetIKRotation(m_Goal, Quaternion.LookRotation(transform.forward) * Quaternion.Euler(m_Offset)); m_Animator.SetIKRotationWeight(m_Goal, 1); } } }