IKPuppetLookTarget.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik //
  2. using UnityEngine;
  3. namespace Animancer.Samples.InverseKinematics
  4. {
  5. /// <summary>An object for a character to look at using Inverse Kinematics (IK).</summary>
  6. ///
  7. /// <remarks>
  8. /// <strong>Sample:</strong>
  9. /// <see href="https://kybernetik.com.au/animancer/docs/samples/ik/puppet">
  10. /// Puppet</see>
  11. /// </remarks>
  12. ///
  13. /// https://kybernetik.com.au/animancer/api/Animancer.Samples.InverseKinematics/IKPuppetLookTarget
  14. ///
  15. [AddComponentMenu(Strings.SamplesMenuPrefix + "Inverse Kinematics - IK Puppet Look Target")]
  16. [AnimancerHelpUrl(typeof(IKPuppetLookTarget))]
  17. public class IKPuppetLookTarget : MonoBehaviour
  18. {
  19. /************************************************************************************************************************/
  20. [SerializeField, Range(0, 1)] private float _Weight = 1;
  21. [SerializeField, Range(0, 1)] private float _BodyWeight = 0.3f;
  22. [SerializeField, Range(0, 1)] private float _HeadWeight = 0.6f;
  23. [SerializeField, Range(0, 1)] private float _EyesWeight = 1;
  24. [SerializeField, Range(0, 1)] private float _ClampWeight = 0.5f;
  25. /************************************************************************************************************************/
  26. public void UpdateAnimatorIK(Animator animator)
  27. {
  28. animator.SetLookAtWeight(_Weight, _BodyWeight, _HeadWeight, _EyesWeight, _ClampWeight);
  29. animator.SetLookAtPosition(transform.position);
  30. }
  31. /************************************************************************************************************************/
  32. }
  33. }