요약
메서드
현재 진동 값이 지정된 UserInputType 및 Enum.VibrationMotor에 설정되어 반환됩니다.
지정된 모터가 지정된 Enum.UserInputType 와 함께 사용할 수 있는 경우 true 를 반환합니다.
지정된 Enum.UserInputType 가 하aptic 피드백을 지원하는 경우 true 를 반환합니다.
- SetMotor(inputType : Enum.UserInputType,vibrationMotor : Enum.VibrationMotor,vibrationValues : Tuple):()
지정된 UserInputType 및 Enum.VibrationMotor의 진동 강도를 설정합니다.
속성
메서드
GetMotor
현재 진동 값이 지정된 UserInputType 및 Enum.VibrationMotor에 설정되어 반환됩니다.이 작업은 SetMotor() 가 먼저 호출되지 않았으면 아무것도 반환하지 않습니다.
매개 변수
지정된 Enum.UserInputType .
지정된 Enum.VibrationMotor .
반환
지정된 Enum.UserInputType 및 Enum.VibrationMotor 또는 nil 에 현재 진동 값이 설정되어 이전에 SetMotor() 가 호출되지 않은 경우
IsMotorSupported
지정된 모터가 지정된 Enum.UserInputType 와 함께 사용할 수 있는 경우 true 를 반환합니다.
매개 변수
특정 Enum.UserInputType가 지원을 위해 검사되고 있습니다. Enum.VibrationMotor
지정된 Enum.VibrationMotor 을 확인하여 지정된 Enum.UserInputType 를 지원하는지 확인했습니다.
반환
지정된 모터가 지정된 true 와 함께 사용할 수 있는 경우, 지정된 Enum.UserInputType 가 없으면 false 입니다.
IsVibrationSupported
지정된 Enum.UserInputType 가 하aptic 피드백을 지원하는 경우 true 를 반환합니다.
매개 변수
지정된 Enum.UserInputType에 체크되어 해프틱 피드백을 지원하는지 확인했습니다.
반환
지정된 true 가 해프틱 피드백을 지원하는 경우 부울 Enum.UserInputType .
SetMotor
지정된 inputType 및 vibrationMotor의 진동 강도를 설정합니다.거의 모든 사용 사례가 내부적으로 기기각각의 하드웨어에 매핑되는 inputType에 대해 Enum.UserInputType.Gamepad1를 지정하는 것을 알아두십시오.
매개 변수
지정된 Enum.UserInputType .
지정된 Enum.VibrationMotor .
모터가 얼마나 강하게 진동해야 하는지. 숫자여야 하는 튜플의 첫 번째 값만 사용합니다.
반환
코드 샘플
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)