ConstraintRotation.cs 725 B

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