How would one make a mobile shiftlock?
Asked by
6 years ago Edited 6 years ago
Hello I attempted to mimic Roblox's shiftlock so I can apply it to mobile players and it works okay but when I equip a tool my character goes a little crazy, sometimes it feels like it's speeds up and slows down.
LocalScript:
01 | local player = game:GetService( "Players" ).LocalPlayer |
03 | while not player.Character do wait() end |
04 | local humanoidRootPart = player.Character.HumanoidRootPart |
06 | local camera = workspace.CurrentCamera |
08 | game:GetService( "RunService" ).RenderStepped:Connect( function () |
09 | local offset = (camera.CFrame.p - humanoidRootPart.Position).unit |
11 | humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position) * CFrame.Angles( 0 , math.pi / 2 - math.atan 2 (offset.Z, offset.X), 0 ) |
Second thoughts I think it is due to me changing the HumanoidRootPart's CFrame in a LocalScript. The normal way out would be to use RemoteEvents, correct?? But there would be a slight delay and Roblox's shiftlock does not have a delay so neither do I want it.
Thanks for any help!!