HapticService
*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.
Özet
Özellikler
Yöntemler
Mevcut vibrasyon değeri belirtilen UserInputType ve Enum.VibrationMotor 'ye ayarlanır ve döndürür.
Belirtilen motor, belirtilen ile kullanılabilir durumda ise döndürür.
Belirtilen Enum.UserInputType destekler geri dönüşgeri bildirim içeriyorsa true döndürür.
- SetMotor(inputType : Enum.UserInputType,vibrationMotor : Enum.VibrationMotor,vibrationValues : Tuple):()
Belirtilen UserInputType ve Enum.VibrationMotor 'in titreşim yoğunluğunu ayarlar.
Özellikler
Yöntemler
GetMotor
Mevcut vibrasyon değeri belirtilen UserInputType ve Enum.VibrationMotor 'ye ayarlanır ve döndürür.Bu, SetMotor() önceden çağrılmadıysa hiçbir şey dönmeyecektir.
Parametreler
Belirtilen Enum.UserInputType .
Belirtilen Enum.VibrationMotor .
Dönüşler
Belirtilen Enum.UserInputType ve Enum.VibrationMotor veya nil değerine ayarlanan mevcut titreşim değeri, SetMotor() önceden çağrılmadıysa.
IsMotorSupported
Belirtilen motor, belirtilen ile kullanılabilir durumda ise döndürür.
Parametreler
Özel Enum.UserInputType destek için kontrol ediliyor Enum.VibrationMotor .
Belirtilen Enum.VibrationMotor , belirtilen Enum.UserInputType 'i desteklediğini görmek için kontrol edildi.
Dönüşler
Belirtilen motor, belirtilen true ile kullanılabilecekse ve belirtilen Enum.UserInputType ile kullanılamıyorsa, false değilse.
IsVibrationSupported
Belirtilen Enum.UserInputType destekler geri dönüşgeri bildirim içeriyorsa true döndürür.
Parametreler
Belirtilen Enum.UserInputType haptik geri bildirim desteklediğini görmek için kontrol edildi.
Dönüşler
Belirtilen true eğer özel Enum.UserInputType geri dönüşgeri bildirim destekliyorsa.
SetMotor
Belirtilen inputType ve vibrationMotor 'in titreşim yoğunluğunu ayarlar.Neredeyse tüm kullanım durumları, cihazın ilgili donanımına içsel olarak yönlendirilen inputType için Enum.UserInputType.Gamepad1 belirtir.
Parametreler
Belirtilen Enum.UserInputType .
Belirtilen Enum.VibrationMotor .
Motorun ne kadar yoğun titreşmesi gerekiyor. Sadece tuple'daki ilk değeri kullanır, ki bu bir sayı olmalıdır.
Dönüşler
Kod Örnekleri
This example makes the small motor vibrate depending on how much pressure is applied to the left trigger, and the large motor vibrate depending on how much pressure is applied to the right trigger.
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
-- Watch this input manually to accurately update the vibration motor
cachedInputs[input] = input.Changed:Connect(onInputChanged)
end
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)