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.
As far as I know, joystick movement causes the .InputChanged even tot be fired.
To detect either the left or right joystick, one should simply only have to check what keycode it is.
function OnInputChanged(Input : InputObject, ignore : boolean)
if Input.KeyCode == Enum.KeyCode.Thumbstick1 then
print("Left Stick: ", Input.Delta, Input.Position)
elseif Input.KeyCode == Enum.KeyCode.Thumbstick2 then
print("Right Stick: ", Input.Delta, Input.Position)
end
end
This should do it basically, I’m pretty sure it still works to this day?
Position should give you a Vector that gives the exact analog position of the joystick in question.
While Delta should tell how fast it moved into a direction within a frame.
If I’m not mistaken the Delta value can change depending on frame rate but that’s just a theory, I have not tested that actually since I rarely ever use that.
Input systems might also just have their own update/tick cycle that is not tied to frame rate.
I made these myself. I didn’t notice it needed the input object, so what you need is actually :GetMouse(). I took time out of my day to help you. I appreciate you saying that these are ai generated because now I am literally going to destroy everything in my sight now that you have said that. My day is ruined and my pain is immeasurable. I am losing my mind. But it is not me who is at fault for the destruction of my surroundings. It is yours. So be proud. Be proud of what you have accomplished