HapticService

Artık kullanılmayanları göster

*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.

Oluşturulamaz
Hizmet
Çoğaltılmamış

Özet

Yöntemler

Ö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 .

Varsayılan değer: ""
vibrationMotor: Enum.VibrationMotor

Belirtilen Enum.VibrationMotor .

Varsayılan değer: ""

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 .

Varsayılan değer: ""
vibrationMotor: Enum.VibrationMotor

Belirtilen Enum.VibrationMotor , belirtilen Enum.UserInputType 'i desteklediğini görmek için kontrol edildi.

Varsayılan değer: ""

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.

Varsayılan değer: ""

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 .

Varsayılan değer: ""
vibrationMotor: Enum.VibrationMotor

Belirtilen Enum.VibrationMotor .

Varsayılan değer: ""
vibrationValues: Tuple

Motorun ne kadar yoğun titreşmesi gerekiyor. Sadece tuple'daki ilk değeri kullanır, ki bu bir sayı olmalıdır.

Varsayılan değer: ""

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.

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
-- Watch this input manually to accurately update the vibration motor
cachedInputs[input] = input.Changed:Connect(onInputChanged)
end
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)

Etkinlikler