rotation.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. private var BSvar = 0.5;
  2. private var pomakU = 0.0;
  3. private var pomakV = 0.0;
  4. private var soffsetU = 0.0;
  5. private var soffsetV = 0.0;
  6. private var KoefU = 0.0;
  7. private var KoefV = 0.0;
  8. private var deltaKoefU = 0.0;
  9. private var deltaKoefV = 0.0;
  10. private var TT = 0.0;
  11. private var apsTT = 0.0;
  12. private var TTstat = 1;
  13. private var BSPU = 0.0;
  14. private var BSPV = 0.0;
  15. private var Yspeed = 1;
  16. private var Tok = 0.0;
  17. function Update() {
  18. if (TTstat == 1){
  19. if (Input.GetKeyDown (KeyCode.Keypad1)){
  20. if (KoefU !=0.2122 && Time.time > Tok){
  21. Tok = Time.time + BSvar;
  22. deltaKoefU = 0.2122 - KoefU;
  23. deltaKoefV = 0- KoefV;
  24. KoefU = 0.2122;
  25. KoefV = 0;
  26. TTstat = 0;
  27. }
  28. }
  29. if (Input.GetKeyDown (KeyCode.Keypad5)){
  30. if (KoefU !=0.9145 && Time.time > Tok){
  31. Tok = Time.time + BSvar;
  32. deltaKoefU = 0.9145 - KoefU;
  33. deltaKoefV = 0- KoefV;
  34. KoefU = 0.9145;
  35. KoefV = 0;
  36. TTstat = 0;
  37. }
  38. }
  39. if (Input.GetKeyDown (KeyCode.Keypad4)){
  40. if (KoefU !=0.1486 && Time.time > Tok){
  41. Tok = Time.time + BSvar;
  42. deltaKoefU = 0.1486 - KoefU;
  43. deltaKoefV = 0- KoefV;
  44. KoefU = 0.1486;
  45. KoefV = 0;
  46. TTstat = 0;
  47. }
  48. }
  49. if (Input.GetKeyDown (KeyCode.Keypad0)){
  50. if (KoefU != -0.1224 && Time.time > Tok){
  51. deltaKoefU = -0.1224 - KoefU;
  52. deltaKoefV = 0 - KoefV;
  53. KoefU = -0.1224;
  54. KoefV = 0;
  55. TTstat = 0;
  56. }
  57. }
  58. if (Input.GetKeyDown (KeyCode.Keypad2)){
  59. if (KoefV != -0.1143 && Time.time > Tok){
  60. Tok = Time.time + BSvar;
  61. deltaKoefV = -0.1143 - KoefV;
  62. deltaKoefU = 0 - KoefU;
  63. KoefV = -0.1143;
  64. KoefU = 0;
  65. TTstat = 0;
  66. }
  67. }
  68. if (Input.GetKeyDown (KeyCode.Keypad3)){
  69. if (KoefV != 0.1143 && Time.time > Tok){
  70. Tok = Time.time + BSvar;
  71. deltaKoefV = 0.1143 - KoefV;
  72. deltaKoefU = 0 - KoefU;
  73. KoefV = 0.1143;
  74. KoefU = 0;
  75. TTstat = 0;
  76. }
  77. }
  78. if (Input.GetKeyDown (KeyCode.Keypad6)){
  79. deltaKoefV = 0 - KoefV;
  80. deltaKoefU = 0 - KoefU;
  81. KoefV = 0;
  82. KoefU = 0;
  83. TTstat = 0;
  84. }
  85. if (Input.GetKeyDown (KeyCode.Keypad7)){
  86. deltaKoefV = 0 - KoefV;
  87. deltaKoefU = 0 - KoefU;
  88. KoefV = 0;
  89. KoefU = 0;
  90. TTstat = 0;
  91. }
  92. if (Input.GetKeyDown (KeyCode.Keypad8)){
  93. deltaKoefV = 0 - KoefV;
  94. deltaKoefU = 0 - KoefU;
  95. KoefV = 0;
  96. KoefU = 0;
  97. TTstat = 0;
  98. }
  99. if (Input.GetKeyDown (KeyCode.Keypad9)){
  100. deltaKoefV = 0 - KoefV;
  101. deltaKoefU = 0 - KoefU;
  102. KoefV = 0;
  103. KoefU = 0;
  104. TTstat = 0;
  105. }
  106. if (Input.GetKeyDown (KeyCode.S)){
  107. deltaKoefV = 0 - KoefV;
  108. deltaKoefU = 0 - KoefU;
  109. KoefV = 0;
  110. KoefU = 0;
  111. TTstat = 0;
  112. }
  113. if (Input.GetKeyDown (KeyCode.I)){
  114. deltaKoefV = 0 - KoefV;
  115. deltaKoefU = 0 - KoefU;
  116. KoefV = 0;
  117. KoefU = 0;
  118. TTstat = 0;
  119. }
  120. if (Input.GetKeyDown (KeyCode.T)){
  121. deltaKoefV = 0 - KoefV;
  122. deltaKoefU = 0 - KoefU;
  123. KoefV = 0;
  124. KoefU = 0;
  125. TTstat = 0;
  126. }
  127. }
  128. if ( TTstat == 0) {
  129. apsTT = apsTT + Time.deltaTime;
  130. TT = apsTT / BSvar;
  131. if (apsTT > 0.5){
  132. TTstat = 1;
  133. TT = 1;
  134. apsTT = 0.0;
  135. }
  136. }
  137. if ( deltaKoefU > 0 ){
  138. BSPU = KoefU * TT;
  139. soffsetU = Time.deltaTime * BSPU;
  140. pomakU = pomakU + soffsetU;
  141. }
  142. if (deltaKoefU < 0){
  143. BSPU = KoefU - (deltaKoefU - (deltaKoefU * TT));
  144. soffsetU = Time.deltaTime * BSPU;
  145. pomakU = pomakU + soffsetU;
  146. }
  147. if ( deltaKoefV > 0 ){
  148. BSPV = KoefV * TT;
  149. soffsetV = Time.deltaTime * BSPV;
  150. pomakV = pomakV + soffsetV;
  151. }
  152. if (deltaKoefV < 0){
  153. BSPV = KoefV - (deltaKoefV - (deltaKoefV * TT));
  154. soffsetV = Time.deltaTime * BSPV;
  155. pomakV = pomakV + soffsetV;
  156. }
  157. transform.Rotate(-((soffsetU*4)/25.1327)*360, 0, ((soffsetV*4)/12.56)*360, Space.World);
  158. }