Advertisement
ManityMan

Test (Reanimated startup anim)

Dec 19th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | None | 0 0
  1. character.Animate.Parent = nil
  2.  
  3. local newMotor = function(part0, part1, c0, c1)
  4.     local w = Create('Weld'){
  5.         Parent = part0,
  6.         Part0 = part0,
  7.         Part1 = part1,
  8.         C0 = c0,
  9.         C1 = c1,
  10.     }
  11.     return w
  12. end
  13.  
  14. function clerp(a, b, t)
  15.     return a:lerp(b, t)
  16. end
  17.  
  18. RootCF = CFrame.fromEulerAnglesXYZ(-1.57, 0, 3.14)
  19. NeckCF = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  20.  
  21. local RW = newMotor(Torso, RightArm, CFrame.new(1.5, 0, 0), CFrame.new(0, 0, 0))
  22. local LW = newMotor(Torso, LeftArm, CFrame.new(-1.5, 0, 0), CFrame.new(0, 0, 0))
  23. local RH = newMotor(Torso, RightLeg, CFrame.new(.5, -2, 0), CFrame.new(0, 0, 0))
  24. local LH = newMotor(Torso, LeftLeg, CFrame.new(-.5, -2, 0), CFrame.new(0, 0, 0))
  25. RootJoint.C1 = CFrame.new(0, 0, 0)
  26. RootJoint.C0 = CFrame.new(0, 0, 0)
  27. Torso.Neck.C1 = CFrame.new(0, 0, 0)
  28. Torso.Neck.C0 = CFrame.new(0, 1.5, 0)
  29.  
  30. local rarmc1 = RW.C1
  31. local larmc1 = LW.C1
  32. local rlegc1 = RH.C1
  33. local llegc1 = LH.C1
  34.  
  35. local resetc1 = false
  36.  
  37. function PlayAnimationFromTable(table, speed, bool)
  38.     RootJoint.C0 = clerp(RootJoint.C0, table[1], speed)
  39.     Torso.Neck.C0 = clerp(Torso.Neck.C0, table[2], speed)
  40.     RW.C0 = clerp(RW.C0, table[3], speed)
  41.     LW.C0 = clerp(LW.C0, table[4], speed)
  42.     RH.C0 = clerp(RH.C0, table[5], speed)
  43.     LH.C0 = clerp(LH.C0, table[6], speed)
  44.     LH.C1 = clerp(LH.C1,CFrame.new(0,0,0),speed)
  45.     RH.C1 = clerp(RH.C1,CFrame.new(0,0,0),speed)
  46.     if bool == true then
  47.         if resetc1 == false then
  48.             resetc1 = true
  49.             RootJoint.C1 = RootJoint.C1
  50.             Torso.Neck.C1 = Torso.Neck.C1
  51.             RW.C1 = rarmc1
  52.             LW.C1 = larmc1
  53.             RH.C1 = rlegc1
  54.             LH.C1 = llegc1
  55.         end
  56.     end
  57. end
  58.  
  59. ArtificialHB = Create("BindableEvent", script){
  60.     Parent = script,
  61.     Name = "Heartbeat",
  62. }
  63.  
  64. script:WaitForChild("Heartbeat")
  65.  
  66. frame = 1 / 30
  67. tf = 0
  68. allowframeloss = false
  69. tossremainder = false
  70. lastframe = tick()
  71. script.Heartbeat:Fire()
  72.  
  73. game:GetService("RunService").Heartbeat:connect(function(s, p)
  74.     tf = tf + s
  75.     if tf >= frame then
  76.         if allowframeloss then
  77.             script.Heartbeat:Fire()
  78.             lastframe = tick()
  79.         else
  80.             for i = 1, math.floor(tf / frame) do
  81.                 script.Heartbeat:Fire()
  82.             end
  83.             lastframe = tick()
  84.         end
  85.         if tossremainder then
  86.             tf = 0
  87.         else
  88.             tf = tf - frame * math.floor(tf / frame)
  89.         end
  90.     end
  91. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement