Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game:GetService("Players").LocalPlayer
- local ControllerService = game:GetService("ControllerService")
- local InputService = game:GetService("UserInputService")
- local RenderStepped = game:GetService("RunService").RenderStepped
- local ControllerSensitivity = 3
- repeat wait() until Player.Character ~= nil
- local Char = Player.Character
- local Torso = Char:WaitForChild("HumanoidRootPart")
- local Humanoid = Char:WaitForChild("Humanoid")
- local GamepadEnabled = InputService.GamepadEnabled
- local Inputs = {}
- local Thumb1Pos = Vector2.new(0,0)
- function Connected()
- print("connected, bruh")
- GamepadEnabled = true
- end
- function CheckConnected()
- GamepadEnabled = not GamepadEnabled -- Like that?
- end
- function Disconnected()
- print("nooo") -- wot, why? Just because you're using two functions.
- GamepadEnabled = false --//Ugly method lel.
- end
- function InputBegan(Input)
- if GamepadEnabled then
- print(Input.KeyCode) -- We need to start by seeing what input it's getting.
- Inputs[Input.KeyCode] = Input
- while Inputs[Input.KeyCode] ~= nil do
- if Input.KeyCode == Enum.KeyCode.ButtonA then
- Humanoid.Jump = true
- elseif Input.KeyCode == Enum.KeyCode.ButtonX then -- testing
- --Humanoid.Parent:BreakJoints()
- end
- wait(0.1)
- end
- end
- end
- function InputChanged(Input)
- if Input.KeyCode == Enum.KeyCode.Thumbstick1 or Input.KeyCode == Enum.KeyCode.Thumbstick2 then
- Inputs[Input.KeyCode] = Input
- end
- end
- function InputEnded(Input)
- Inputs[Input.KeyCode] = nil
- if Input.KeyCode == Enum.KeyCode.Thumbstick1 then
- Humanoid:MoveTo(Torso.Position,Workspace.Terrain)
- end
- end
- InputService.GamepadConnected:connect(Connected)
- InputService.GamepadDisconnected:connect(Disconnected)
- InputService.InputBegan:connect(InputBegan)
- InputService.InputChanged:connect(InputChanged)
- InputService.InputEnded:connect(InputEnded)
- while true do
- for i,v in pairs(Inputs) do
- if v.KeyCode == Enum.KeyCode.Thumbstick2 then
- local Dis = (Torso.Position-Workspace.CurrentCamera.CoordinateFrame.p).Magnitude
- local CFr = Workspace.CurrentCamera.CoordinateFrame*CFrame.new(0,0,-Dis)
- local CFr2 = CFrame.new(Vector3.new(Workspace.CurrentCamera.CoordinateFrame.X,CFr.Y,Workspace.CurrentCamera.CoordinateFrame.Z),CFr.p)
- CFr2 = CFrame.new(CFr.p)*(CFr2-(CFr2.p))
- local X = math.deg((CFr:toObjectSpace(CFr2):toEulerAnglesXYZ()))
- local Ratio = 1
- if X > 0 and X < 90 then
- Ratio = 1-(X/90)
- elseif X < 0 and X > -90 then
- Ratio = 1-(X/-90)
- end
- Ratio = Ratio*2
- if Ratio > 1 then
- Ratio = 1
- end
- local New = Workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(math.rad(v.Position.Y*(ControllerSensitivity)),-math.rad(v.Position.X*(ControllerSensitivity*Ratio)),0)*CFrame.new(0,0,-Dis)
- if X >= 75 and X <= 90 and v.Position.Y < 0 then
- New = Workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(0,-math.rad(v.Position.X*(ControllerSensitivity*Ratio)),0)*CFrame.new(0,0,-Dis)
- elseif X >= -90 and X <= -75 and v.Position.Y > 0 then
- New = Workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(0,-math.rad(v.Position.X*(ControllerSensitivity*Ratio)),0)*CFrame.new(0,0,-Dis)
- end
- Workspace.CurrentCamera.Focus = New
- elseif v.KeyCode == Enum.KeyCode.Thumbstick1 then
- local Dir = Vector3.new(v.Position.X,0,-v.Position.Y)
- local NewDir = Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(Dir).unit*100
- Humanoid:MoveTo((Workspace.CurrentCamera.CoordinateFrame+NewDir).p,Workspace.Terrain)
- end
- end
- RenderStepped:wait()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement