Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5.  
  6.  
  7. public class PULSO_FingersAnimator : MonoBehaviour {
  8.  
  9. public Transform[] _f0Bones;
  10. Quaternion[] _f0StartRots;
  11.  
  12. public Transform[] _f1Bones;
  13. Quaternion[] _f1StartRots;
  14.  
  15. public Transform[] _f2Bones;
  16. Quaternion[] _f2StartRots;
  17.  
  18. public Transform[] _f3Bones;
  19. Quaternion[] _f3StartRots;
  20.  
  21. public Transform[] _f4Bones;
  22. Quaternion[] _f4StartRots;
  23.  
  24. [Range(0f, 1f)]
  25. public float _f0Angle = 1;
  26.  
  27. [Range(0f, 1f)]
  28. public float _f1Angle = 1;
  29.  
  30. [Range(0f, 1f)]
  31. public float _f2Angle = 1;
  32.  
  33. [Range(0f, 1f)]
  34. public float _f3Angle = 1;
  35.  
  36. [Range(0f, 1f)]
  37. public float _f4Angle = 1;
  38.  
  39. [Range(0f, 1f)]
  40. public float _f5Angle = 1;
  41.  
  42.  
  43. public float _from;
  44. public float _to;
  45.  
  46. public float _fromB;
  47. public float _toB;
  48.  
  49. public float _fromBS;
  50. public float _toBS;
  51.  
  52.  
  53.  
  54. void Start ()
  55. {
  56. _f0StartRots = new Quaternion[_f0Bones.Length];
  57. for (int i = 0; i < _f0Bones.Length; i++) {
  58. _f0StartRots [i] = _f0Bones [i].localRotation;
  59. }
  60.  
  61. _f1StartRots = new Quaternion[_f1Bones.Length];
  62. for (int i = 0; i < _f1Bones.Length; i++) {
  63. _f1StartRots [i] = _f1Bones [i].localRotation;
  64. }
  65.  
  66. _f2StartRots = new Quaternion[_f2Bones.Length];
  67. for (int i = 0; i < _f2Bones.Length; i++) {
  68. _f2StartRots [i] = _f2Bones [i].localRotation;
  69. }
  70.  
  71. _f3StartRots = new Quaternion[_f3Bones.Length];
  72. for (int i = 0; i < _f3Bones.Length; i++) {
  73. _f3StartRots [i] = _f3Bones [i].localRotation;
  74. }
  75.  
  76. _f4StartRots = new Quaternion[_f4Bones.Length];
  77. for (int i = 0; i < _f4Bones.Length; i++) {
  78. _f4StartRots [i] = _f4Bones [i].localRotation;
  79. }
  80. }
  81.  
  82.  
  83. void LateUpdate()
  84. {
  85. if (WeaponManager._instance != null)
  86. {
  87. if (WeaponManager._instance._selectedGun != -1)
  88. {
  89. if (WeaponManager._instance._selectedGun == 0 || WeaponManager._instance._selectedGun == 1)
  90. {
  91. _f1Bones [2].localRotation = _f1StartRots [2] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f1Angle));
  92. }
  93.  
  94. if (WeaponManager._instance._selectedGun == 2)
  95. {
  96. for (int i = 0; i < _f0Bones.Length; i++)
  97. {
  98. _f0Bones [i].localRotation = _f0StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f0Angle));
  99. }
  100. }
  101. }
  102. }
  103. }
  104.  
  105.  
  106. void Update ()
  107. {
  108.  
  109. for (int i = 0; i < _f0Bones.Length; i++)
  110. {
  111. _f0Bones [i].localRotation = _f0StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_fromB, _toB, _f0Angle));
  112. }
  113.  
  114. for (int i = 0; i < _f1Bones.Length; i++)
  115. {
  116. _f1Bones [i].localRotation = _f1StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f1Angle));
  117. }
  118.  
  119. for (int i = 0; i < _f2Bones.Length; i++)
  120. {
  121. _f2Bones [i].localRotation = _f2StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f2Angle));
  122. }
  123.  
  124. for (int i = 0; i < _f3Bones.Length; i++)
  125. {
  126. _f3Bones [i].localRotation = _f3StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f3Angle));
  127. }
  128.  
  129. for (int i = 0; i < _f4Bones.Length; i++)
  130. {
  131. _f4Bones [i].localRotation = _f4StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f4Angle));
  132. }
  133. }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement