Some games have mobile haptics how can i add mobile haptics.
1 Like
You can use HapticService to add vibration on mobile devices, but unfortunately as support for mobile devices was added very recently by this service (August 2022), there aren’t any specific instructions or documentations on which motors mobile devices use/support, so you’ll need to experiment. The most common ones are Small
and Large
.
1 Like
can you write a example script
1 Like
local hapticService = game:GetService("HapticService")
function hapticFeedbackMobile(vibrationMotor, vibrationLength, vibrationValues)
if hapticService:IsMotorSupported(Enum.UserInputType.Gamepad1, vibrationMotor) then
hapticService:SetMotor(Enum.UserInputType.Gamepad1, vibrationMotor, vibrationValues)
wait(vibrationLength)
hapticService:SetMotor(Enum.UserInputType.Gamepad1, vibrationMotor, 0)
end
end
--Enable vibration on motor Large for 2 seconds at intensity 1
hapticFeedbackMobile(Enum.VibrationMotor.Large, 2, 1)
5 Likes
change 4th line to if hapticService:IsMotorSupported(Enum.UserInputType.Gamepad1, vibrationMotor) then
3 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.