UserInputService = game:GetService("UserInputService")
UserInputService.InputChanged:Connect(function(inputObj)
print(inputObj.UserInputType)
if (inputObj.UserInputType == Enum.UserInputType.Touch) or (inputObj.UserInputType == Enum.UserInputType.MouseButton2) then
print('changed! ',inputObj)
end
end)
Works with mobile touch, but not with a mouse.
Is this expected?
(Use mobile emulator to test )
I’m working on custom camera panning, and this makes things more difficult.
@YellowBannana898 I’m not trying to detect mouse click, I’m trying to detect mouse-click-and-drag.
Also, yes, I know MouseButton2 is right mouse button.
@sizquirt The emulator works fine. You just have to click here.
My camera type is already set to scriptable, but this has nothing to do with cameras.
Here’s my full camera script. I’m working on panning for my game’s orthographic camera.
-- ToldFable 2022
local CameraCircleAngleRad = 0
local panHeight = 0
local cameraMagnitude = 2000--2500
local Player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = nil
Camera.FieldOfView = 0
local lookingAtPos = Vector3.new(0,-80,0)
function Pan(inputObj)
local oldPosition = inputObj.Position - inputObj.Delta
--print(touch.Delta.Y)
--print("Touch moved from " .. tostring(oldPosition) .. "to " .. tostring(touch.Position))
CameraCircleAngleRad += (inputObj.Delta.X/200)
--panHeight += (touch.Position.Y/20)
panHeight += inputObj.Delta.Y*10
end
UserInputService.InputChanged:Connect(function(inputObj)
if inputObj.UserInputType == Enum.UserInputType.Touch then
--or inputObj.UserInputType == Enum.UserInputType.MouseButton1 then -- weird behavior
print('changed')
Pan(inputObj)
end
end)
while true do
wait()
local cameraOrigin = Vector3.new((math.cos(CameraCircleAngleRad)*cameraMagnitude),2000,(math.sin(CameraCircleAngleRad)*cameraMagnitude))
Camera.CFrame = CFrame.new(cameraOrigin,lookingAtPos+Vector3.new(0,(cameraMagnitude/2500)*100*panHeight/3000,0))
--CameraCircleAngleRad += 0.01
end