Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local user_settings = UserSettings():GetService("UserGameSettings")
- local user_input = UserInputService:GetMouseDelta()*0.01*user_settings.MouseSensitivity
- local fov = self.camera_fov:update(delta_time)
- local walk_speed = self.character_walkspeed:update(delta_time)
- local scalar = self.move_vector.Magnitude/self.character_walkspeed.target
- local speed = walk_speed
- if user_input == Vector2.new() then
- self.seconds_without_movement += delta_time
- else
- self.seconds_without_movement = 0
- end
- UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
- UserInputService.MouseIconEnabled = false
- -- # update camera
- self.character_cframe *= CFrame.new(-user_input.y, -user_input.x, 0)
- self.flashlight_spring:shove(Vector3.new(user_input.x*5, user_input.y*5))
- self.camera_roll:increment(user_input.x*0.2)
- self.camera_roll:multiply(delta_time*30)
- -- # clamp axis
- local clamp_x = math.clamp(self.character_cframe.x, -1.3, 1.3) - self.character_cframe.x
- self.character_cframe *= CFrame.new(clamp_x, 0, 0)
- -- # set cframe
- self.camera.FieldOfView = fov
- self.camera.CFrame = CFrame.new(self.character.head.Position)
- * CFrame.Angles(0, self.character_cframe.y, self.character_cframe.z)
- * CFrame.Angles(self.character_cframe.x, 0, self.camera_roll:update(delta_time))
- self.camera.CFrame = self.camera.CFrame:ToWorldSpace(CFrame.new(0, 0, -0.5))
- -- # character update
- self.character.Humanoid.WalkSpeed = walk_speed
- -- # movement
- self.camera.CFrame *= CFrame.Angles(util.cycle(scalar, speed), 0, util.cycle(scalar*0.25, speed))
- self.camera.CFrame *= CFrame.Angles(0, 0, -self.move_vector.x*0.05)
- self.camera.CFrame += Vector3.new(0, math.sin((tick()*speed)-0.5)*scalar*0.1, 0)
- -- # flashlight
- local flashlight_movement = self.flashlight_spring:update(delta_time)
- self.flashlight.CFrame = self.camera.CFrame * CFrame.Angles(flashlight_movement.y, flashlight_movement.x, flashlight_movement.x)
- self.flashlight.light.Enabled = self.flashlight_enable
- if self.interaction_disabled then
- self.flashlight_enable = false
- end
- -- # act
- if self.current_act then
- self.current_act.update(delta_time)
- end
- -- tool
- if self.tool then
- local new_cframe = self.camera.CFrame:ToWorldSpace(self.tool.offsets.idle.Value)
- self.tool:SetPrimaryPartCFrame(new_cframe)
- end
- if self.camera_target then
- self.camera.CFrame = self.camera_target.CFrame
- if self.camera_target_allow_interaction then
- local clamp_vert = self.camera_target_clamp_vert or 0.1
- local clamp_horiz = self.camera_target_clamp_vert or 0.1
- self.character_cframe = CFrame.new(
- math.clamp(self.character_cframe.x, -clamp_vert, clamp_vert),
- math.clamp(self.character_cframe.y, -clamp_horiz, clamp_horiz),
- self.character_cframe.z
- )
- self.camera.CFrame
- *= CFrame.Angles(0, self.character_cframe.y, self.character_cframe.z)
- * CFrame.Angles(self.character_cframe.x, 0, self.camera_roll:update(delta_time))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement