HapticService

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

만들 수 없음
서비스
복제되지 않음

현대 컨트롤러 및 기기에는 모터가 내장되어 있습니다. 럼블 및 진동을 추가하면 시각적 개체 또는 오디오를 통해 표시하기 어려운 미묘한 피드백을 제공할 수 있습니다.

Roblox는 다음과 같은 장치에 대해 손떨림을 지원합니다.

  • 대부분의 iPhone, Pixel 및 Samsung Galaxy 장치를 지원하는 안드로이드 및 iOS 전화기
  • PlayStation 게임 패드
  • Xbox 게임 패드
  • 퀘스트 터치 컨트롤러

요약

메서드

속성

메서드

GetMotor

현재 진동 값 집합을 지정된 UserInputTypeEnum.VibrationMotor 에 반환합니다. 이전에 SetMotor 이 호출되지 않았으면 반환하는 것이 없습니다.

매개 변수

vibrationMotor: Enum.VibrationMotor

반환

현재 진동 값은 지정된 Enum.UserInputTypeEnum.VibrationMotor 또는 일반적으로 사용하는 SetMotor 에 설정된 값과 같습니다.

IsMotorSupported

지정된 모터를 사용할 수 있는지 여부가 Enum.UserInputType 와 함께 사용할 수 있는지 여부를 반환합니다.

매개 변수

Enzym.UserInputType 이 있는 경우 Enum.VibrationMotor 지원을 위해 확인됩니다.

vibrationMotor: Enum.VibrationMotor

지정된 Enum.VibrationMotor 을 확인하여 지정된 Enum.UserInputType 을 지원하는지 여부를 확인합니다.


반환

지정된 모터를 사용할 수 있는 경우 True, 사용할 수 없는 경우 아니.

IsVibrationSupported

지정된 Enum.UserInputType가 하프픽티 피드백을 지원하면 트루를 반환합니다.

매개 변수

지정된 Enum.UserInputType 은 손 움직임 피드백을 지원하는지 여부를 확인하기 위해 확인됩니다.


반환

Enum.UserInputType 이 하프픽스 피드백을 지원하는 경우 True.

SetMotor

void

지정된 UserInputTypeEnum.VibrationMotor의 진동 강도를 설정합니다. 거의 모든 사용 사례에서 Gamepad1 을 2>Class.InputObject.UserInputType2> 로 지정합니다.

매개 변수

vibrationMotor: Enum.VibrationMotor
vibrationValues: Tuple

모터가 얼마나 강하게 진동해야 합니까. 숫자여야 하는 첫 번째 값만 사용합니다.


반환

void

코드 샘플

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)

이벤트