using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using NaughtyAttributes;
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class IkController : MonoBehaviour
|
|
{
|
|
|
|
#region Inspector Fields
|
|
|
|
[SerializeField, BoxGroup("References")]
|
|
private HandController m_leftHandTarget, m_rightHandTarget;
|
|
|
|
[SerializeField, BoxGroup("References")]
|
|
private Animator m_animator;
|
|
|
|
[SerializeField, BoxGroup("Settings"),Range(0,1)]
|
|
public float IKWeight = 1;
|
|
|
|
#endregion Inspector Fields
|
|
|
|
#region Private Fields
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Getters
|
|
|
|
#endregion Getters
|
|
|
|
|
|
|
|
#region MonoBehaviour Functions
|
|
/// <summary>
|
|
/// OnEnable is called when the object becomes enabled and active.
|
|
/// </summary>
|
|
private void OnEnable()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// OnDisable is called when the behaviour becomes disabled.
|
|
/// </summary>
|
|
private void OnDisable()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update is called once per frame
|
|
/// </summary>
|
|
private void Update()
|
|
{
|
|
|
|
}
|
|
|
|
//a callback for calculating IK
|
|
void OnAnimatorIK()
|
|
{
|
|
if (m_animator)
|
|
{
|
|
|
|
m_animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
|
|
m_animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
|
|
|
|
m_animator.SetIKPosition(AvatarIKGoal.LeftHand, m_leftHandTarget.GetIKPosition());
|
|
m_animator.SetIKRotation(AvatarIKGoal.LeftHand, m_leftHandTarget.GetIKRotation());
|
|
|
|
|
|
m_animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
|
|
m_animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
|
|
|
|
m_animator.SetIKPosition(AvatarIKGoal.RightHand, m_rightHandTarget.GetIKPosition());
|
|
m_animator.SetIKRotation(AvatarIKGoal.RightHand, m_rightHandTarget.GetIKRotation());
|
|
|
|
}
|
|
}
|
|
|
|
#endregion MonoBehaviour Functions
|
|
|
|
#region Class Functionality
|
|
|
|
#endregion Class Functionality
|
|
|
|
#region Editor Functions
|
|
/// <summary>
|
|
/// Called when the Component is created or Reset from the Inspector
|
|
/// </summary>
|
|
private void Reset()
|
|
{
|
|
//useful for finding components on creation
|
|
}
|
|
#endregion Editor Functions
|
|
|
|
}
|