HapticService

Mostrar obsoleto

*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.

No creable
Servicio
No replicado

Resumen

Métodos

Propiedades

Métodos

GetMotor

Parámetros

Valor predeterminado: ""
vibrationMotor: Enum.VibrationMotor
Valor predeterminado: ""

Devuelve

IsMotorSupported

Parámetros

Valor predeterminado: ""
vibrationMotor: Enum.VibrationMotor
Valor predeterminado: ""

Devuelve

IsVibrationSupported

Parámetros

Valor predeterminado: ""

Devuelve

SetMotor

()

Parámetros

Valor predeterminado: ""
vibrationMotor: Enum.VibrationMotor
Valor predeterminado: ""
vibrationValues: Tuple
Valor predeterminado: ""

Devuelve

()

Muestras de código

Servicio haptico: 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
-- Observe esta entrada manualmente para actualizar con precisión el motor de vibración
cachedInputs[input] = input.Changed:Connect(onInputChanged)
end
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)

Eventos