namespace UnityEngine.Animations.Rigging { /// /// The DampedTransform constraint data. /// [System.Serializable] public struct DampedTransformData : IAnimationJobData, IDampedTransformData { [SerializeField] Transform m_ConstrainedObject; [SyncSceneToStream, SerializeField] Transform m_Source; [SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_DampPosition; [SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_DampRotation; [NotKeyable, SerializeField] bool m_MaintainAim; /// public Transform constrainedObject { get => m_ConstrainedObject; set => m_ConstrainedObject = value; } /// public Transform sourceObject { get => m_Source; set => m_Source = value; } /// /// Damp position weight. Defines how much of constrained object position follows source object position. /// Constrained position will closely follow source object when set to 0, and will /// not move when set to 1. /// public float dampPosition { get => m_DampPosition; set => m_DampPosition = Mathf.Clamp01(value); } /// /// Damp rotation weight. Defines how much of constrained object rotation follows source object rotation. /// Constrained rotation will closely follow source object when set to 0, and will /// not move when set to 1. /// public float dampRotation { get => m_DampRotation; set => m_DampRotation = Mathf.Clamp01(value); } /// public bool maintainAim { get => m_MaintainAim; set => m_MaintainAim = value; } /// string IDampedTransformData.dampPositionFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_DampPosition)); /// string IDampedTransformData.dampRotationFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_DampRotation)); /// bool IAnimationJobData.IsValid() => !(m_ConstrainedObject == null || m_Source == null); /// void IAnimationJobData.SetDefaultValues() { m_ConstrainedObject = null; m_Source = null; m_DampPosition = 0.5f; m_DampRotation = 0.5f; m_MaintainAim = true; } } /// /// DampedTransform constraint. /// [DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Damped Transform")] [HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/DampedTransform.html")] public class DampedTransform : RigConstraint< DampedTransformJob, DampedTransformData, DampedTransformJobBinder > { /// protected override void OnValidate() { base.OnValidate(); m_Data.dampPosition = Mathf.Clamp01(m_Data.dampPosition); m_Data.dampRotation = Mathf.Clamp01(m_Data.dampRotation); } } }