요약
메서드
GetMotor(inputType: Enum.UserInputType,vibrationMotor: Enum.VibrationMotor):Tuple |
IsMotorSupported(inputType: Enum.UserInputType,vibrationMotor: Enum.VibrationMotor):boolean |
IsVibrationSupported(inputType: Enum.UserInputType):boolean |
SetMotor(inputType: Enum.UserInputType,vibrationMotor: Enum.VibrationMotor,vibrationValues: Tuple):() |
상속된 멤버
API 참조
메서드
GetMotor
매개 변수
반환
IsMotorSupported
HapticService:IsMotorSupported(
매개 변수
반환
IsVibrationSupported
매개 변수
반환
SetMotor
HapticService:SetMotor(
):()
매개 변수
반환
()
코드 샘플
HapticService:SetMotor()
local UserInputService = game:GetService("UserInputService")
local HapticService = game:GetService("HapticService")
local cachedInputs = {}
local keyToVibration = {
[Enum.KeyCode.ButtonL2] = Enum.VibrationMotor.Small,
[Enum.KeyCode.ButtonR2] = Enum.VibrationMotor.Large,
}
local function onInputChanged(property)
if property == "Position" then
HapticService:SetMotor(inputType, vibrationMotor, input.Position.Z)
end
end
local function onInputBegan(input)
if not cachedInputs[input] then
local inputType = input.UserInputType
if inputType.Name:find("Gamepad") then
local vibrationMotor = keyToVibration[input.KeyCode]
if vibrationMotor then
-- 이 입력을 수동으로 관찰하여 진동 모터를 정확하게 업데이트합니다
cachedInputs[input] = input.Changed:Connect(onInputChanged)
end
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)