I found this in a free model and its the reason why my game doesn’t work on mobile or console. can anyone explain to me how I could fix it?
this is used in a camera script.
code:
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
local delta = Vector2.new(inputObject.Delta.x/Sensitivity,inputObject.Delta.y/Sensitivity) * Smoothness
local X = TargetAngleX - delta.y
TargetAngleX = (X >= 80 and 80) or (X <= -80 and -80) or X
TargetAngleY = (TargetAngleY - delta.x) %360
end
input.InputChanged:connect(function(inputObject)
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
local delta = Vector2.new(inputObject.Delta.x/Sensitivity,inputObject.Delta.y/Sensitivity) * Smoothness
local X = TargetAngleX - delta.y
TargetAngleX = (X >= 80 and 80) or (X <= -80 and -80) or X
TargetAngleY = (TargetAngleY - delta.x) %360
end
end)
I found out the reason why. It’s because mobile and console don’t have mouse movements, so I need to figure out a way to get thumbstick movement and screen movement
local function update()
local delta = Vector2.new(inputObject.Delta.x/Sensitivity,inputObject.Delta.y/Sensitivity) * Smoothness
local X = TargetAngleX - delta.y
TargetAngleX = (X >= 80 and 80) or (X <= -80 and -80) or X
TargetAngleY = (TargetAngleY - delta.x) %360
end
game:GetService("RunService"):BindToRenderStep("CameraThing", 1, update)
If you plan on trying to take input again for controller, though it’s from 2019, here’s a thread where various issues were tackled:
Make sure there’s a deadzone for controllers, Roblox at that time apparently had 0.2 for theirs. Maybe you want your vectors in your code to be zeros. Some info might be outdated, but hope that helps. Maybe C_Corpze can jump in here.
As for Touch, I’m not sure. There’s likely another thread on the forum for that. I’d assume you can use the TouchGui from Roblox (a screen gui only automatically added if the player has touch input). There’s the camera UI stuff in there. There’s probably a far better way though.