エンジンクラス
HapticService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
方法
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(
):()
パラメータ
戻り値
()
コードサンプル
ハプティックサービス:モーターを設定する()
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)