Informacje o wersji
Edukacja
Klasa silnika
HapticService
Przestarzałe
Brak możliwości tworzenia
Usługa
Bez replikacji

*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.


Podsumowanie
Członkowie odziedziczeni

Materiały referencyjne dotyczące interfejsów API
Metody
GetMotor
Możliwości: Input
HapticService:GetMotor(
inputType:Enum.UserInputType, vibrationMotor:Enum.VibrationMotor
Parametry
vibrationMotor:Enum.VibrationMotor
Zwroty

IsMotorSupported
Możliwości: Input
HapticService:IsMotorSupported(
inputType:Enum.UserInputType, vibrationMotor:Enum.VibrationMotor
Parametry
vibrationMotor:Enum.VibrationMotor
Zwroty

IsVibrationSupported
Możliwości: Input
HapticService:IsVibrationSupported(inputType:Enum.UserInputType):boolean
Parametry
Zwroty

SetMotor
Możliwości: Input
HapticService:SetMotor(
inputType:Enum.UserInputType, vibrationMotor:Enum.VibrationMotor, vibrationValues:Tuple
):()
Parametry
vibrationMotor:Enum.VibrationMotor
vibrationValues:Tuple
Zwroty
()
Przykłady kodu
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
-- Obserwuj ten input ręcznie, aby dokładnie zaktualizować silnik wibracji
cachedInputs[input] = input.Changed:Connect(onInputChanged)
end
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)

©2026 Roblox Corporation. Nazwa Roblox, logo Roblox oraz hasło „Powering Imagination” należą do naszych zarejestrowanych i niezarejestrowanych znaków towarowych na terenie Stanów Zjednoczonych oraz w innych krajach.