Guest User

Untitled

a guest
Oct 14th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. local TweenObjectCFrame do
  2. local HalfPi= math.pi/2
  3. local acos= math.acos
  4. local sin= math.sin
  5. local cf= CFrame.new
  6. local Divide= cf().toObjectSpace
  7. local Components= cf().components
  8. local tick= tick
  9. local RenderStepped= game:GetService("RunService").RenderStepped
  10.  
  11. local TweeningData= {}
  12.  
  13. function TweenObjectCFrame(Object,Index,NextCFrame,Time)-- Object=
  14. if TweeningData[Object] and TweeningData[Object][Index] then
  15. TweeningData[Object][Index]:disconnect()
  16. end
  17.  
  18. local LastCFrame= Object[Index]
  19. local x, y, z,
  20. xx,yx,zx,
  21. xy,yy,zy,
  22. xz,yz,zz= Components(Divide(LastCFrame,NextCFrame))
  23.  
  24. local qw,qx,qy,qz
  25. local th
  26. local s
  27. local tr= xx+yy+zz
  28. if tr>2.99999 then
  29. s= 1
  30. th= 0.1
  31. qw,qx,qy,qz= 1,0,0,0
  32. elseif tr>-0.99999 then
  33. local m= 2*(tr+1)^0.5
  34. qw= m/4
  35. qx= (yz-zy)/m
  36. qy= (zx-xz)/m
  37. qz= (xy-yx)/m
  38. th= acos(qw)
  39. s= (1-qw*qw)^0.5
  40. else
  41. qw= 0
  42. qx= xx+yx+zx+1
  43. qy= xy+yy+zy+1
  44. qz= xz+yz+zz+1
  45. local m= (qx*qx+qy*qy+qz*qz)^0.5
  46. qx,qy,qz= qx/m,qy/m,qz/m
  47. th= HalfPi
  48. s= 1
  49. end
  50.  
  51. local t0= tick()
  52.  
  53. local RenderObject
  54. RenderObject=RenderStepped:connect(function()
  55. local t= (tick()-t0)/Time
  56. if t>1 then
  57. Object[Index]= NextCFrame
  58. RenderObject:disconnect()
  59. TweeningData[Object]=nil
  60. return
  61. end
  62. local s1= sin(th*t)/s
  63. Object[Index]= LastCFrame*cf(
  64. t*x,t*y,t*z,
  65. s1*qx,
  66. s1*qy,
  67. s1*qz,
  68. sin(th*(1-t))/s+s1*qw
  69. )
  70. end)
  71. TweeningData[Object]={
  72. [Index]=RenderObject;
  73. }
  74. end
  75. end
  76.  
  77. return function(Object,Index,NextCFrame,Time)
  78. TweenObjectCFrame(Object,Index,NextCFrame,Time)
  79. end
Advertisement
Add Comment
Please, Sign In to add comment