Advertisement
wackeyhd5cool

Untitled

May 25th, 2020
1,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. local i = Vector3.new()
  2. local n = 0;
  3. game:GetService("RunService"):BindToRenderStep("Movement",Enum.RenderPriority.Camera.Value - 1,function(Num_dt)
  4.    
  5.  
  6.  
  7.     local V3_add = Vector3.new()
  8.    
  9.     for i,v in pairs(ControlManager.MovementKeysDown) do
  10.         if i == Enum.KeyCode.W then
  11.             V3_add = V3_add+Vector3.new(0,0,-1)
  12.         elseif i == Enum.KeyCode.S then
  13.             V3_add = V3_add+Vector3.new(0,0,1)
  14.         elseif i == Enum.KeyCode.D then
  15.             V3_add = V3_add+Vector3.new(1,0,0)
  16.         elseif i == Enum.KeyCode.A then
  17.             V3_add = V3_add+Vector3.new(-1,0,0)
  18.         end
  19.     end
  20.    
  21.     if V3_add.Magnitude > 0 then
  22.         ControlManager.IsRunning = true
  23.         local V3_dir = V3_add/(V3_add.Magnitude)   
  24.         if ControlManager.Camera then
  25.             print("Begin: "..tostring(n).." - "..tostring(tick()))
  26. --[[                       
  27. --          local CF_hrp = Inst_player.Character.HumanoidRootPart.CFrame
  28. --          local V3_lv = ControlManager.Camera.Camera.CFrame.lookVector
  29. --         
  30. --         
  31. --         
  32. --         
  33. --          local CF_pos =
  34. --                      CFrame.new(
  35. --                          CF_hrp.p,
  36. --                          (CFrame.new(CF_hrp.p)*CFrame.new(V3_lv.X,0,V3_lv.Z)).p
  37. --                      )
  38. --                      *CFrame.new(V3_normal*ControlManager.SpeedMultiplier*(Num_dt)) 
  39. --                         
  40. --          local V3_cPos = Vector3.new(V3_lv.X * V3_normal.X,0,V3_lv.Z * V3_normal.Z)
  41. --         
  42. --          print((CF_pos.p - i).magnitude,V3_normal)
  43. --          i = CF_pos.p
  44. --                         
  45. --         
  46. --          local CF_rot = CF_hrp - CF_hrp.p
  47. --         
  48. --          Inst_player.Character:SetPrimaryPartCFrame(CFrame.new(CF_pos.p)*CF_rot)
  49. ]]
  50.                        
  51.             local CF_curHrp = Inst_player.Character.HumanoidRootPart.CFrame
  52.             local V3_camLv = ControlManager.Camera.Camera.CFrame.lookVector
  53.            
  54.            
  55.             local CF_rot = CFrame.new(Vector3.new(),Vector3.new(V3_camLv.X,0,V3_camLv.Z))
  56.             local CF_hrpPos = CFrame.new(CF_curHrp.p)
  57.             local CF_deltaCF = CFrame.new(V3_dir*ControlManager.SpeedMultiplier*Num_dt)
  58.            
  59.             local CF_new = CF_hrpPos*CF_rot*CF_deltaCF
  60.             print((CF_new.p - i).magnitude,"\t \t \t",CF_rot.p.magnitude,"\t \t \t",CF_deltaCF.p.magnitude,"\t \t \t",V3_dir)
  61.             i = CF_new.p           
  62.  
  63.             Inst_player.Character:SetPrimaryPartCFrame(CF_new)
  64.             --Inst_player:Move(V3_dir,true)
  65.            
  66.             print("End: "..tostring(n).." - "..tostring(tick()))
  67.            
  68.             n = n + 1
  69.  
  70.         end
  71.        
  72.        
  73.  
  74.     else
  75.         ControlManager.IsRunning = false
  76.     end
  77.    
  78.    
  79.  
  80. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement