You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.5 KiB
C#
36 lines
1.5 KiB
C#
2 months ago
|
// Animancer // Copyright 2020 Kybernetik //
|
||
|
|
||
|
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value.
|
||
|
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace Animancer.Examples.InverseKinematics
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// An object for one of a character's limbs to aim at using Inverse Kinematics (IK).
|
||
|
/// </summary>
|
||
|
[AddComponentMenu(Strings.MenuPrefix + "Examples/Inverse Kinematics - IK Puppet Target")]
|
||
|
[HelpURL(Strings.APIDocumentationURL + ".Examples.InverseKinematics/IKPuppetTarget")]
|
||
|
public sealed class IKPuppetTarget : MonoBehaviour
|
||
|
{
|
||
|
/************************************************************************************************************************/
|
||
|
|
||
|
[SerializeField] private AvatarIKGoal _Type;
|
||
|
[SerializeField, Range(0, 1)] private float _PositionWeight = 1;
|
||
|
[SerializeField, Range(0, 1)] private float _RotationWeight = 0;
|
||
|
|
||
|
/************************************************************************************************************************/
|
||
|
|
||
|
public void UpdateAnimatorIK(Animator animator)
|
||
|
{
|
||
|
animator.SetIKPositionWeight(_Type, _PositionWeight);
|
||
|
animator.SetIKRotationWeight(_Type, _RotationWeight);
|
||
|
|
||
|
animator.SetIKPosition(_Type, transform.position);
|
||
|
animator.SetIKRotation(_Type, transform.rotation);
|
||
|
}
|
||
|
|
||
|
/************************************************************************************************************************/
|
||
|
}
|
||
|
}
|