เรียนรู้
Engine Class
HapticService
เลิกใช้แล้ว
ไม่สามารถสร้าง
บริการ
ไม่ซ้ำ

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
วิธีการ
SetMotor(inputType: Enum.UserInputType,vibrationMotor: Enum.VibrationMotor,vibrationValues: Tuple):()
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
GetMotor
ความสามารถ: Input
HapticService:GetMotor(
inputType:Enum.UserInputType, vibrationMotor:Enum.VibrationMotor
พารามิเตอร์
vibrationMotor:Enum.VibrationMotor
ส่งค่ากลับ

IsMotorSupported
ความสามารถ: Input
HapticService:IsMotorSupported(
inputType:Enum.UserInputType, vibrationMotor:Enum.VibrationMotor
พารามิเตอร์
vibrationMotor:Enum.VibrationMotor
ส่งค่ากลับ

IsVibrationSupported
ความสามารถ: Input
HapticService:IsVibrationSupported(inputType:Enum.UserInputType):boolean
พารามิเตอร์
ส่งค่ากลับ

SetMotor
ความสามารถ: Input
HapticService:SetMotor(
inputType:Enum.UserInputType, vibrationMotor:Enum.VibrationMotor, vibrationValues:Tuple
):()
พารามิเตอร์
vibrationMotor:Enum.VibrationMotor
vibrationValues:Tuple
ส่งค่ากลับ
()
ตัวอย่างโค้ด
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)

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ