Advertisement
theblackshibe

Untitled

Jan 3rd, 2021
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. local user_settings = UserSettings():GetService("UserGameSettings")
  2. local user_input = UserInputService:GetMouseDelta()*0.01*user_settings.MouseSensitivity
  3. local fov = self.camera_fov:update(delta_time)
  4. local walk_speed = self.character_walkspeed:update(delta_time)
  5. local scalar = self.move_vector.Magnitude/self.character_walkspeed.target
  6. local speed = walk_speed
  7.  
  8. if user_input == Vector2.new() then
  9. self.seconds_without_movement += delta_time
  10. else
  11. self.seconds_without_movement = 0
  12. end
  13.  
  14. UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
  15. UserInputService.MouseIconEnabled = false
  16.  
  17. -- # update camera
  18. self.character_cframe *= CFrame.new(-user_input.y, -user_input.x, 0)
  19. self.flashlight_spring:shove(Vector3.new(user_input.x*5, user_input.y*5))
  20. self.camera_roll:increment(user_input.x*0.2)
  21. self.camera_roll:multiply(delta_time*30)
  22.  
  23. -- # clamp axis
  24. local clamp_x = math.clamp(self.character_cframe.x, -1.3, 1.3) - self.character_cframe.x
  25. self.character_cframe *= CFrame.new(clamp_x, 0, 0)
  26.  
  27. -- # set cframe
  28. self.camera.FieldOfView = fov
  29. self.camera.CFrame = CFrame.new(self.character.head.Position)
  30. * CFrame.Angles(0, self.character_cframe.y, self.character_cframe.z)
  31. * CFrame.Angles(self.character_cframe.x, 0, self.camera_roll:update(delta_time))
  32. self.camera.CFrame = self.camera.CFrame:ToWorldSpace(CFrame.new(0, 0, -0.5))
  33.  
  34. -- # character update
  35. self.character.Humanoid.WalkSpeed = walk_speed
  36.  
  37. -- # movement
  38. self.camera.CFrame *= CFrame.Angles(util.cycle(scalar, speed), 0, util.cycle(scalar*0.25, speed))
  39. self.camera.CFrame *= CFrame.Angles(0, 0, -self.move_vector.x*0.05)
  40. self.camera.CFrame += Vector3.new(0, math.sin((tick()*speed)-0.5)*scalar*0.1, 0)
  41.  
  42. -- # flashlight
  43. local flashlight_movement = self.flashlight_spring:update(delta_time)
  44. self.flashlight.CFrame = self.camera.CFrame * CFrame.Angles(flashlight_movement.y, flashlight_movement.x, flashlight_movement.x)
  45. self.flashlight.light.Enabled = self.flashlight_enable
  46.  
  47. if self.interaction_disabled then
  48. self.flashlight_enable = false
  49. end
  50.  
  51. -- # act
  52. if self.current_act then
  53. self.current_act.update(delta_time)
  54. end
  55.  
  56. -- tool
  57. if self.tool then
  58. local new_cframe = self.camera.CFrame:ToWorldSpace(self.tool.offsets.idle.Value)
  59. self.tool:SetPrimaryPartCFrame(new_cframe)
  60. end
  61.  
  62. if self.camera_target then
  63. self.camera.CFrame = self.camera_target.CFrame
  64. if self.camera_target_allow_interaction then
  65.  
  66. local clamp_vert = self.camera_target_clamp_vert or 0.1
  67. local clamp_horiz = self.camera_target_clamp_vert or 0.1
  68.  
  69. self.character_cframe = CFrame.new(
  70. math.clamp(self.character_cframe.x, -clamp_vert, clamp_vert),
  71. math.clamp(self.character_cframe.y, -clamp_horiz, clamp_horiz),
  72. self.character_cframe.z
  73. )
  74.  
  75. self.camera.CFrame
  76. *= CFrame.Angles(0, self.character_cframe.y, self.character_cframe.z)
  77. * CFrame.Angles(self.character_cframe.x, 0, self.camera_roll:update(delta_time))
  78. end
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement