Ghi chú phát hành
Học
Lớp công cụ
HapticService
Đã Lỗi Thời
Không Thể Tạo
Dịch Vụ
Không Sao Chép

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Phương Pháp
SetMotor(inputType: Enum.UserInputType,vibrationMotor: Enum.VibrationMotor,vibrationValues: Tuple):()
Thành viên kế thừa

Tài Liệu Tham Khảo API
Phương Pháp
GetMotor
Các khả năng: Input
HapticService:GetMotor(
inputType:Enum.UserInputType, vibrationMotor:Enum.VibrationMotor
Tham Số
vibrationMotor:Enum.VibrationMotor
Lợi Nhuận

IsMotorSupported
Các khả năng: Input
HapticService:IsMotorSupported(
inputType:Enum.UserInputType, vibrationMotor:Enum.VibrationMotor
Tham Số
vibrationMotor:Enum.VibrationMotor
Lợi Nhuận

IsVibrationSupported
Các khả năng: Input
HapticService:IsVibrationSupported(inputType:Enum.UserInputType):boolean
Tham Số
Lợi Nhuận

SetMotor
Các khả năng: Input
HapticService:SetMotor(
inputType:Enum.UserInputType, vibrationMotor:Enum.VibrationMotor, vibrationValues:Tuple
):()
Tham Số
vibrationMotor:Enum.VibrationMotor
vibrationValues:Tuple
Lợi Nhuận
()
Mẫu mã
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
-- Theo dõi đầu vào này thủ công để cập nhật chính xác động cơ rung
cachedInputs[input] = input.Changed:Connect(onInputChanged)
end
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.