Apr 1st, 2020
Here at Roblox we’re constantly looking for ways to improve the player experience across all platforms and devices. As part of this effort, we’ve implemented a brand new camera mode to help with camera control on laptops and desktops. Meet Camera Toggle. Instructions Tap RMB to switch into toggle mode. Tap RMB again to switch out of toggle mode. Toggle mode puts the cursor above your head.
Never
Not a member of Pastebin yet?Sign Up, it unlocks many cool features!
- --Services
- local RunService = game:GetService('RunService')
- local TweenService = game:GetService('TweenService')
- --Player
- repeat wait()until Player.Character
- repeat wait()until Player.Character.HumanoidRootPart
- local HumanoidRootPart = Character.HumanoidRootPart
- local CamScript = Player.PlayerScripts.CameraScript
- Humanoid.AutoRotate =false
- --Mouse
- local Popper =true-- Sets whether Popper Cam behaviour is enabled
- local DeltaY =0
- local AngleV =0
- local SensitivityY =120-- Determines how large a change in vertical angle is through a mouse rotation
- local SensitivityX =120-- Determines how large a change in the horizontal angle is through a mouse rotation
- local A =false
- local D =false
- local Offset = CFrame.new(2,3,15)-- Determines the CFrame by which the camera is pushed from the CFrame of the HumanoidRootPart
- local MaxY =5*math.pi/12-- Determines maximum vertical angle
- local MinY =-5*math.pi/12-- Determines minimum vertical angle
- {true,false,false,false,0,0},
- {false,true,false,false,math.pi/2},
- {false,false,true,false,math.pi},
- {false,false,false,true,3*math.pi/2},
- }
- --Camera
- Cam.CameraType = Enum.CameraType.Scriptable
- local FakeCam = Cam:Clone()
- --Functions
- AngleH = AngleH - DeltaX/SensitivityX
- AngleV =math.clamp(AngleV - DeltaY/SensitivityY, MinY, MaxY)
- local FinalCFrame = CFrame.new(HumanoidRootPart.Position)* CFrame.Angles(0, AngleH,0)* CFrame.Angles(AngleV,0,0)* Offset
- if(Popper true)then
- local Direction =(FinalCFrame.p - Character.Head.Position).Unit *((Offset.p).Magnitude)
- local CheckRay = Ray.new(Character.Head.Position, Direction)
- local Part, Position = game.Workspace:FindPartOnRay(CheckRay, Character,false,true)
- local Distance = Cam:GetLargestCutoffDistance({Character})
- Cam.CoordinateFrame = Cam.CoordinateFrame * CFrame.new(0,0,-Distance)
- end
- if(W true)or(A true)or(S true)or(D true)then
- if(Val[1] W)and(Val[2] A)and(Val[3] S)and(Val[4] D)then
- local DirectionVector = Cam.CoordinateFrame.lookVector
- local TargetCFrame = CFrame.new(HumanoidRootPart.Position, HumanoidRootPart.Position + Vector3.new(DirectionVector.X,0, DirectionVector.Z))
- HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:lerp(TargetCFrame * CFrame.Angles(0, Val[5],0),0.25)
- end
- end)
- UIS.InputChanged:Connect(function(Input, Bool)
- if(Input.UserInputType Enum.UserInputType.MouseMovement)then
- DeltaX = Input.Delta.X
- if(DeltaY ~= Input.Delta.Y)then
- end
- end
- if(Bool false)then
- W =true
- A =true
- S =true
- D =true
- end
- if(Bool false)then
- W =false
- A =false
- S =false
- D =false
- end
RAW Paste Data