현대 컨트롤러 및 기기에는 모터가 내장되어 있습니다. 럼블 및 진동을 추가하면 시각적 개체 또는 오디오를 통해 표시하기 어려운 미묘한 피드백을 제공할 수 있습니다.
Roblox는 다음과 같은 장치에 대해 손떨림을 지원합니다.
- 대부분의 iPhone, Pixel 및 Samsung Galaxy 장치를 지원하는 안드로이드 및 iOS 전화기
- PlayStation 게임 패드
- Xbox 게임 패드
- 퀘스트 터치 컨트롤러
요약
메서드
현재 진동 값 집합을 지정된 UserInputType 및 Enum.VibrationMotor 에 반환합니다. 이전에 SetMotor 이 호출되지 않았으면 반환하는 것이 없습니다.
지정된 모터를 사용할 수 있는지 여부가 Enum.UserInputType 와 함께 사용할 수 있는지 여부를 반환합니다.
지정된 Enum.UserInputType가 하프픽티 피드백을 지원하면 트루를 반환합니다.
- SetMotor(inputType : Enum.UserInputType,vibrationMotor : Enum.VibrationMotor,vibrationValues : Tuple):void
지정된 UserInputType 및 Enum.VibrationMotor의 진동 강도를 설정합니다.
속성
메서드
GetMotor
현재 진동 값 집합을 지정된 UserInputType 및 Enum.VibrationMotor 에 반환합니다. 이전에 SetMotor 이 호출되지 않았으면 반환하는 것이 없습니다.
매개 변수
지정된 Enum.UserInputType .
지정된 Enum.VibrationMotor .
반환
현재 진동 값은 지정된 Enum.UserInputType 및 Enum.VibrationMotor 또는 일반적으로 사용하는 SetMotor 에 설정된 값과 같습니다.
IsMotorSupported
지정된 모터를 사용할 수 있는지 여부가 Enum.UserInputType 와 함께 사용할 수 있는지 여부를 반환합니다.
매개 변수
Enzym.UserInputType 이 있는 경우 Enum.VibrationMotor 지원을 위해 확인됩니다.
지정된 Enum.VibrationMotor 을 확인하여 지정된 Enum.UserInputType 을 지원하는지 여부를 확인합니다.
반환
지정된 모터를 사용할 수 있는 경우 True, 사용할 수 없는 경우 아니.
IsVibrationSupported
지정된 Enum.UserInputType가 하프픽티 피드백을 지원하면 트루를 반환합니다.
매개 변수
지정된 Enum.UserInputType 은 손 움직임 피드백을 지원하는지 여부를 확인하기 위해 확인됩니다.
반환
Enum.UserInputType 이 하프픽스 피드백을 지원하는 경우 True.
SetMotor
지정된 UserInputType 및 Enum.VibrationMotor의 진동 강도를 설정합니다. 거의 모든 사용 사례에서 Gamepad1 을 2>Class.InputObject.UserInputType2> 로 지정합니다.
매개 변수
반환
코드 샘플
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)