ConstraintPosition.cs 712 B

12345678910111213141516171819202122232425262728293031323334
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace RootMotion.FinalIK {
  4. /// <summary>
  5. /// %Constraints to position in world space.
  6. /// </summary>
  7. [System.Serializable]
  8. public class ConstraintPosition : Constraint {
  9. #region Main Interface
  10. /// <summary>
  11. /// The target position.
  12. /// </summary>
  13. public Vector3 position;
  14. public override void UpdateConstraint() {
  15. if (weight <= 0) return;
  16. if (!isValid) return;
  17. // Lerping to position
  18. transform.position = Vector3.Lerp(transform.position, position, weight);
  19. }
  20. #endregion Main Interface
  21. public ConstraintPosition() {}
  22. public ConstraintPosition(Transform transform) {
  23. this.transform = transform;
  24. }
  25. }
  26. }